diff --git a/pkg/docker/cli.go b/pkg/docker/cli.go index bbccbe8..c9ed195 100644 --- a/pkg/docker/cli.go +++ b/pkg/docker/cli.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -42,7 +43,7 @@ type clientImpl struct { client *client.Client } -func (c *clientImpl) listImages(timeout time.Duration) ([]types.ImageSummary, error) { +func (c *clientImpl) listImages(timeout time.Duration) ([]image.Summary, error) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return c.client.ImageList(ctx, types.ImageListOptions{ @@ -92,7 +93,7 @@ func (c *clientImpl) ListContainersWithTimeout(running bool, timeout time.Durati args.Add("status", status) } - return c.client.ContainerList(ctx, types.ContainerListOptions{ + return c.client.ContainerList(ctx, container.ListOptions{ All: true, Filters: args, }) @@ -101,7 +102,7 @@ func (c *clientImpl) ListContainersWithTimeout(running bool, timeout time.Durati func (c *clientImpl) RemoveContainerWithTimeout(id string, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - return c.client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{ + return c.client.ContainerRemove(ctx, id, container.RemoveOptions{ RemoveVolumes: true, Force: true, }) @@ -151,7 +152,7 @@ func (c *clientImpl) RunContainer(ctx context.Context, config *container.Config, } } - err = c.client.ContainerStart(ctx, ct.ID, types.ContainerStartOptions{}) + err = c.client.ContainerStart(ctx, ct.ID, container.StartOptions{}) if err != nil { return "", fmt.Errorf("start container: %w", err) } diff --git a/pkg/docker/fake/cli.go b/pkg/docker/fake/cli.go index 6c61bc6..0ce4123 100644 --- a/pkg/docker/fake/cli.go +++ b/pkg/docker/fake/cli.go @@ -50,7 +50,7 @@ func (f *Client) WaitContainerWithTimeout(id string, timeout time.Duration) (int return 0, fmt.Errorf("container %s not found", id) } const delay = 5 * time.Second - if timeout < delay { + if timeout > 0 && timeout < delay { time.Sleep(timeout) return 0, context.DeadlineExceeded } diff --git a/pkg/server/repo_handlers_test.go b/pkg/server/repo_handlers_test.go index 61d400b..45b76c7 100644 --- a/pkg/server/repo_handlers_test.go +++ b/pkg/server/repo_handlers_test.go @@ -129,9 +129,6 @@ func TestHandlerSyncRepo(t *testing.T) { Cron: "@every 1h", Image: "alpine:latest", StorageDir: "/data", - Envs: model.StringMap{ - "UPSTREAM": "http://foo.com", - }, }).Error) schedule, _ := cron.ParseStandard("@every 1h") te.server.repoSchedules.Set(name, schedule) @@ -147,15 +144,15 @@ func TestHandlerSyncRepo(t *testing.T) { Name: name, } testutils.PollUntilTimeout(t, time.Minute, func() bool { - require.NoError(t, te.server.db.First(&meta).Error) + require.NoError(t, te.server.db.Take(&meta).Error) return !meta.Syncing }) - require.NoError(t, te.server.db.First(&meta).Error) - require.EqualValues(t, "http://foo.com", meta.Upstream) - require.NotEmpty(t, meta.PrevRun) - require.NotEmpty(t, meta.LastSuccess) - require.NotEmpty(t, meta.NextRun) + require.NoError(t, te.server.db.Take(&meta).Error) + require.NotEmpty(t, meta.PrevRun, "PrevRun") + require.Empty(t, meta.ExitCode, "ExitCode") + require.NotEmpty(t, meta.LastSuccess, "LastSuccess") + require.NotEmpty(t, meta.NextRun, "NextRun") } func TestHandlerRemoveRepo(t *testing.T) {