Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nadim-az committed Jan 16, 2025
1 parent cb1fc71 commit 379af08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
10 changes: 5 additions & 5 deletions core/provider/digitalocean/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type DockerClient interface {
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
ContainerExecCreate(ctx context.Context, container string, config container.ExecOptions) (types.IDResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config container.ExecStartOptions) (types.HijackedResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
Close() error
}
Expand Down Expand Up @@ -77,8 +77,8 @@ func (d *defaultDockerClient) ContainerExecCreate(ctx context.Context, container
return d.client.ContainerExecCreate(ctx, container, options)
}

func (d *defaultDockerClient) ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (types.HijackedResponse, error) {
return d.client.ContainerExecAttach(ctx, execID, config)
func (d *defaultDockerClient) ContainerExecAttach(ctx context.Context, execID string, options container.ExecStartOptions) (types.HijackedResponse, error) {
return d.client.ContainerExecAttach(ctx, execID, options)
}

func (d *defaultDockerClient) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error) {
Expand Down
40 changes: 17 additions & 23 deletions core/provider/docker/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ package docker_test
import (
"context"
"fmt"
"sync"
"testing"
"time"

"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/matoous/go-nanoid/v2"
gonanoid "github.com/matoous/go-nanoid/v2"
"github.com/skip-mev/petri/core/v2/provider/docker"
"go.uber.org/zap/zaptest"
"sync"
"testing"
"time"

"github.com/skip-mev/petri/core/v2/provider"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

const idAlphabet = "abcdefghijklqmnoqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Expand Down Expand Up @@ -48,9 +48,9 @@ func TestCreateProviderDuplicateNetwork(t *testing.T) {

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)
defer func() {
require.NoError(t, p1.Teardown(context.Background()))
}()

p2, err := docker.CreateProvider(ctx, logger, providerName)
require.Error(t, err)
Expand All @@ -67,9 +67,9 @@ func TestCreateProvider(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func(ctx context.Context, p provider.ProviderI) {
defer func() {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)
}()

state := p.GetState()
assert.Equal(t, providerName, state.Name)
Expand Down Expand Up @@ -107,11 +107,9 @@ func TestCreateTask(t *testing.T) {

p, err := docker.CreateProvider(context.Background(), logger, providerName)
require.NoError(t, err)
defer p.Teardown(context.Background())

defer func(ctx context.Context, p provider.ProviderI) {
defer func() {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)
}()

tests := []struct {
name string
Expand Down Expand Up @@ -184,11 +182,9 @@ func TestConcurrentTaskCreation(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
defer func() {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)
}()

numTasks := 10
var wg sync.WaitGroup
Expand Down Expand Up @@ -252,11 +248,9 @@ func TestProviderSerialization(t *testing.T) {

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p1.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)
defer func() {
require.NoError(t, p1.Teardown(ctx))
}()

_, err = p1.CreateTask(ctx, provider.TaskDefinition{
Name: fmt.Sprintf("%s-test-task", providerName),
Expand Down
7 changes: 5 additions & 2 deletions core/provider/docker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import (
"bytes"
"context"
"fmt"
"sync"

"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/go-connections/nat"
"github.com/skip-mev/petri/core/v2/util"
"sync"

// "github.com/docker/docker/api/types/filters"
// "github.com/docker/docker/api/types/image"
// "github.com/docker/docker/api/types/mount"
// "github.com/docker/docker/api/types/network"
// "github.com/docker/docker/pkg/stdcopy"
// "github.com/docker/go-connections/nat"
"time"

"github.com/skip-mev/petri/core/v2/provider"
"go.uber.org/zap"
"time"
)

type TaskState struct {
Expand Down

0 comments on commit 379af08

Please sign in to comment.