diff --git a/go.mod b/go.mod index 66788505c..24954516e 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.62.0 - github.com/docker/cli v27.5.1+incompatible - github.com/docker/docker v27.5.1+incompatible + github.com/docker/cli v28.0.1+incompatible + github.com/docker/docker v28.0.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/ecies/go/v2 v2.0.10 diff --git a/go.sum b/go.sum index ade5b6e3d..41e307ed7 100644 --- a/go.sum +++ b/go.sum @@ -226,13 +226,13 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.5.1+incompatible h1:JB9cieUT9YNiMITtIsguaN55PLOHhBSz3LKVc6cqWaY= -github.com/docker/cli v27.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.0.1+incompatible h1:g0h5NQNda3/CxIsaZfH4Tyf6vpxFth7PYl3hgCPOKzs= +github.com/docker/cli v28.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.5.1+incompatible h1:4PYU5dnBYqRQi0294d1FBECqT9ECWeQAIfE8q4YnPY8= -github.com/docker/docker v27.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.0.1+incompatible h1:FCHjSRdXhNRFjlHMTv4jUNlIBbTeRjrWfeFuJp7jpo0= +github.com/docker/docker v28.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= diff --git a/internal/db/branch/create/create_test.go b/internal/db/branch/create/create_test.go index 8e3842345..66b919ecb 100644 --- a/internal/db/branch/create/create_test.go +++ b/internal/db/branch/create/create_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -60,7 +60,7 @@ func TestBranchCreation(t *testing.T) { // Run test err := createBranch(context.Background(), "test-branch") // Validate api - assert.ErrorContains(t, err, "request returned Service Unavailable for API route and version") + assert.ErrorContains(t, err, "request returned 503 Service Unavailable for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) }) @@ -71,7 +71,7 @@ func TestBranchCreation(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/exec"). Reply(http.StatusCreated). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := createBranch(context.Background(), "test-branch") // Validate api diff --git a/internal/db/branch/switch_/switch__test.go b/internal/db/branch/switch_/switch__test.go index 4e2e1055b..3eca45cd1 100644 --- a/internal/db/branch/switch_/switch__test.go +++ b/internal/db/branch/switch_/switch__test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgerrcode" "github.com/spf13/afero" @@ -34,7 +34,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusServiceUnavailable) @@ -99,7 +99,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := Run(context.Background(), "postgres", fsys) // Check error @@ -117,7 +117,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := Run(context.Background(), "main", fsys) // Check error @@ -135,7 +135,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Setup target branch branch := "main" branchPath := filepath.Join(filepath.Dir(utils.CurrBranchPath), branch) @@ -159,7 +159,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Setup target branch branch := "target" branchPath := filepath.Join(filepath.Dir(utils.CurrBranchPath), branch) @@ -183,7 +183,7 @@ func TestSwitchCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Setup target branch branch := "main" branchPath := filepath.Join(filepath.Dir(utils.CurrBranchPath), branch) diff --git a/internal/db/diff/diff_test.go b/internal/db/diff/diff_test.go index 20094d902..71b03223e 100644 --- a/internal/db/diff/diff_test.go +++ b/internal/db/diff/diff_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" @@ -51,10 +52,10 @@ func TestRun(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-shadow-realtime") @@ -218,8 +219,8 @@ func TestDiffDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: false, Status: "exited", }, @@ -248,10 +249,10 @@ func TestDiffDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -285,10 +286,10 @@ create schema public`) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). diff --git a/internal/db/dump/dump_test.go b/internal/db/dump/dump_test.go index 3a7c3cc65..e8e4b2d1a 100644 --- a/internal/db/dump/dump_test.go +++ b/internal/db/dump/dump_test.go @@ -72,7 +72,7 @@ func TestPullCommand(t *testing.T) { // Run test err := Run(context.Background(), "", dbConfig, nil, nil, false, false, false, false, false, fsys) // Check error - assert.ErrorContains(t, err, "request returned Service Unavailable for API route and version") + assert.ErrorContains(t, err, "request returned 503 Service Unavailable for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) }) diff --git a/internal/db/lint/lint_test.go b/internal/db/lint/lint_test.go index 8d7abef8f..e8f4bc9a0 100644 --- a/internal/db/lint/lint_test.go +++ b/internal/db/lint/lint_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" @@ -38,7 +38,7 @@ func TestLintCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Setup db response expected := Result{ Function: "22751", diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 4e3558be3..bb87bd912 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" @@ -50,7 +51,7 @@ func TestResetCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) gock.New(utils.Docker.DaemonHost()). Delete("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK) @@ -61,10 +62,10 @@ func TestResetCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) // Setup mock postgres @@ -84,10 +85,10 @@ func TestResetCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.StorageId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Config.Api.ExternalUrl). @@ -147,7 +148,7 @@ func TestResetCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) gock.New(utils.Docker.DaemonHost()). Delete("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). ReplyError(errors.New("network error")) @@ -298,10 +299,10 @@ func TestRestartDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) // Restarts services @@ -333,10 +334,10 @@ func TestRestartDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) // Restarts services @@ -389,8 +390,8 @@ func TestRestartDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-reset/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: false, Status: "exited", }, diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index fdc76c6ec..4cad4fb11 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/volume" "github.com/h2non/gock" "github.com/spf13/afero" @@ -71,10 +72,10 @@ func TestStartDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-realtime") @@ -117,10 +118,10 @@ func TestStartDatabase(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) // Run test @@ -147,11 +148,11 @@ func TestStartDatabase(t *testing.T) { ReplyError(errors.New("network error")) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/images/" + utils.GetRegistryImageUrl(utils.Config.Db.Image) + "/json"). - Reply(http.StatusInternalServerError) + Reply(http.StatusServiceUnavailable) // Run test err := StartDatabase(context.Background(), "", fsys, io.Discard) // Check error - assert.ErrorContains(t, err, "request returned Internal Server Error for API route and version") + assert.ErrorContains(t, err, "request returned 503 Service Unavailable for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) }) } @@ -194,7 +195,7 @@ func TestStartCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := Run(context.Background(), "", fsys) // Check error @@ -333,10 +334,10 @@ func TestStartDatabaseWithCustomSettings(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) diff --git a/internal/functions/serve/serve_test.go b/internal/functions/serve/serve_test.go index 81c385bde..5f66d8e93 100644 --- a/internal/functions/serve/serve_test.go +++ b/internal/functions/serve/serve_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -30,7 +30,7 @@ func TestServeCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) containerId := "supabase_edge_runtime_test" gock.New(utils.Docker.DaemonHost()). Delete("/v" + utils.Docker.ClientVersion() + "/containers/" + containerId). @@ -80,7 +80,7 @@ func TestServeCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := Run(context.Background(), ".env", nil, "", RuntimeOption{}, fsys) // Check error @@ -100,7 +100,7 @@ func TestServeCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) // Run test err := Run(context.Background(), ".env", cast.Ptr(true), "import_map.json", RuntimeOption{}, fsys) // Check error diff --git a/internal/gen/types/types_test.go b/internal/gen/types/types_test.go index 811ae061d..bf7ee4067 100644 --- a/internal/gen/types/types_test.go +++ b/internal/gen/types/types_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgconn" "github.com/spf13/afero" @@ -41,7 +41,7 @@ func TestGenLocalCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) apitest.MockDockerStart(utils.Docker, imageUrl, containerId) require.NoError(t, apitest.MockDockerLogs(utils.Docker, containerId, "hello world\n")) // Setup mock postgres @@ -78,7 +78,7 @@ func TestGenLocalCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/images"). Reply(http.StatusServiceUnavailable) @@ -99,7 +99,7 @@ func TestGenLocalCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) apitest.MockDockerStart(utils.Docker, imageUrl, containerId) require.NoError(t, apitest.MockDockerLogs(utils.Docker, containerId, "hello world\n")) // Setup mock postgres diff --git a/internal/migration/squash/squash_test.go b/internal/migration/squash/squash_test.go index b9092d980..bda678b0b 100644 --- a/internal/migration/squash/squash_test.go +++ b/internal/migration/squash/squash_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" @@ -59,10 +60,10 @@ func TestSquashCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -219,8 +220,8 @@ func TestSquashMigrations(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: false, Status: "exited", }, @@ -249,10 +250,10 @@ func TestSquashMigrations(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -284,10 +285,10 @@ func TestSquashMigrations(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/test-shadow-db/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). diff --git a/internal/start/start_test.go b/internal/start/start_test.go index c00d2e92d..d52bc4590 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -9,6 +9,8 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" "github.com/h2non/gock" @@ -52,9 +54,9 @@ func TestStartCommand(t *testing.T) { }) t.Run("show status if database is already running", func(t *testing.T) { - var running []types.Container + var running []container.Summary for _, name := range utils.GetDockerIds() { - running = append(running, types.Container{ + running = append(running, container.Summary{ Names: []string{name + "_test"}, }) } @@ -67,13 +69,15 @@ func TestStartCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). - JSON(types.ContainerJSON{}) + JSON(container.InspectResponse{}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_start/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{Running: true}, + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ + Running: true, + }, }}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). @@ -103,13 +107,13 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/images/" + imageUrl + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) - for _, image := range config.Images.Services() { - service := utils.GetRegistryImageUrl(image) + JSON(image.InspectResponse{}) + for _, img := range config.Images.Services() { + service := utils.GetRegistryImageUrl(img) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/images/" + service + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) } // Start postgres utils.DbId = "test-postgres" @@ -164,14 +168,14 @@ func TestDatabaseStart(t *testing.T) { utils.StorageId, utils.ImgProxyId, utils.EdgeRuntimeId, utils.PgmetaId, utils.StudioId, utils.LogflareId, utils.RestId, utils.VectorId, } - for _, container := range started { + for _, c := range started { gock.New(utils.Docker.DaemonHost()). - Get("/v" + utils.Docker.ClientVersion() + "/containers/" + container + "/json"). + Get("/v" + utils.Docker.ClientVersion() + "/containers/" + c + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) } @@ -185,10 +189,10 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.StorageId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) gock.New(utils.Config.Api.ExternalUrl). @@ -219,7 +223,7 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/images/" + imageUrl + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) // Start postgres utils.DbId = "test-postgres" utils.ConfigId = "test-config" @@ -233,10 +237,10 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ Running: true, - Health: &types.Health{Status: types.Healthy}, + Health: &container.Health{Status: types.Healthy}, }, }}) // Run test diff --git a/internal/status/status_test.go b/internal/status/status_test.go index 01dd1e73b..c7bfc1bc4 100644 --- a/internal/status/status_test.go +++ b/internal/status/status_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -18,9 +18,9 @@ import ( func TestStatusCommand(t *testing.T) { t.Run("shows service status", func(t *testing.T) { - var running []types.Container + var running []container.Summary for _, name := range utils.GetDockerIds() { - running = append(running, types.Container{ + running = append(running, container.Summary{ Names: []string{name + "_test"}, }) } @@ -33,8 +33,10 @@ func TestStatusCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{Running: true}, + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ + Running: true, + }, }}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). @@ -76,9 +78,9 @@ func TestStatusCommand(t *testing.T) { func TestServiceHealth(t *testing.T) { t.Run("checks all services", func(t *testing.T) { - var running []types.Container + var running []container.Summary for _, name := range utils.GetDockerIds() { - running = append(running, types.Container{ + running = append(running, container.Summary{ Names: []string{"/" + name}, }) } @@ -104,7 +106,7 @@ func TestServiceHealth(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) // Run test stopped, err := checkServiceHealth(context.Background()) // Check error diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index 81fad5dee..d260143df 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -8,7 +8,6 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" @@ -32,7 +31,7 @@ func TestStopCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). @@ -69,7 +68,7 @@ func TestStopCommand(t *testing.T) { Get("/v"+utils.Docker.ClientVersion()+"/containers/json"). MatchParam("all", "true"). Reply(http.StatusOK). - JSON([]types.Container{ + JSON([]container.Summary{ {ID: "container1", Labels: map[string]string{utils.CliProjectLabel: "project1"}}, {ID: "container2", Labels: map[string]string{utils.CliProjectLabel: "project2"}}, }) @@ -93,7 +92,7 @@ func TestStopCommand(t *testing.T) { MatchParam("all", "1"). MatchParam("filters", fmt.Sprintf(`{"label":{"com.supabase.cli.project=%s":true}}`, projectId)). Reply(http.StatusOK). - JSON([]types.Container{{ID: "container-" + projectId, State: "running"}}) + JSON([]container.Summary{{ID: "container-" + projectId, State: "running"}}) // Mock container stop gock.New(utils.Docker.DaemonHost()). @@ -120,11 +119,11 @@ func TestStopCommand(t *testing.T) { Get("/v"+utils.Docker.ClientVersion()+"/containers/json"). MatchParam("all", "true"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) // Run test err := Run(context.Background(), true, "", true, fsys) @@ -157,14 +156,14 @@ func TestStopCommand(t *testing.T) { // Run test err := Run(context.Background(), false, "test", false, afero.NewReadOnlyFs(fsys)) // Check error - assert.ErrorContains(t, err, "request returned Service Unavailable for API route and version") + assert.ErrorContains(t, err, "request returned 503 Service Unavailable for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) }) } func TestStopServices(t *testing.T) { t.Run("stops all services", func(t *testing.T) { - containers := []types.Container{{ID: "c1", State: "running"}, {ID: "c2"}} + containers := []container.Summary{{ID: "c1", State: "running"}, {ID: "c2"}} // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) defer gock.OffAll() @@ -232,7 +231,7 @@ func TestStopServices(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). ReplyError(errors.New("network error")) diff --git a/internal/testing/apitest/docker.go b/internal/testing/apitest/docker.go index 556756dfd..17a14355d 100644 --- a/internal/testing/apitest/docker.go +++ b/internal/testing/apitest/docker.go @@ -6,8 +6,8 @@ import ( "net/http" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/volume" @@ -33,11 +33,11 @@ func MockDocker(docker *client.Client) error { } // Ref: internal/utils/docker.go::DockerStart -func MockDockerStart(docker *client.Client, image, containerID string) { +func MockDockerStart(docker *client.Client, imageID, containerID string) { gock.New(docker.DaemonHost()). - Get("/v" + docker.ClientVersion() + "/images/" + image + "/json"). + Get("/v" + docker.ClientVersion() + "/images/" + imageID + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). @@ -61,7 +61,7 @@ func MockDockerStop(docker *client.Client) { gock.New(docker.DaemonHost()). Get("/v" + docker.ClientVersion() + "/containers/json"). Reply(http.StatusOK). - JSON([]types.Container{}) + JSON([]container.Summary{}) gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). @@ -95,9 +95,10 @@ func setupDockerLogs(docker *client.Client, containerID, stdout string, exitCode gock.New(docker.DaemonHost()). Get("/v" + docker.ClientVersion() + "/containers/" + containerID + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSONBase{State: &types.ContainerState{ - ExitCode: exitCode, - }}) + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ + ExitCode: exitCode, + }}}) gock.New(docker.DaemonHost()). Delete("/v" + docker.ClientVersion() + "/containers/" + containerID). Reply(http.StatusOK) diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 84911d07f..792ffb3db 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -239,7 +239,7 @@ func DockerImagePullWithRetry(ctx context.Context, image string, retries int) er func DockerPullImageIfNotCached(ctx context.Context, imageName string) error { imageUrl := GetRegistryImageUrl(imageName) - if _, _, err := Docker.ImageInspectWithRaw(ctx, imageUrl); err == nil { + if _, err := Docker.ImageInspect(ctx, imageUrl); err == nil { return nil } else if !client.IsErrNotFound(err) { return errors.Errorf("failed to inspect docker image: %w", err) diff --git a/internal/utils/docker_test.go b/internal/utils/docker_test.go index 6a0cdf034..069204559 100644 --- a/internal/utils/docker_test.go +++ b/internal/utils/docker_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stdcopy" @@ -52,7 +52,7 @@ func TestPullImage(t *testing.T) { gock.New(Docker.DaemonHost()). Get("/v" + Docker.ClientVersion() + "/images/" + imageId + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) // Run test assert.NoError(t, DockerPullImageIfNotCached(context.Background(), imageId)) // Validate api @@ -130,7 +130,7 @@ func TestRunOnce(t *testing.T) { gock.New(Docker.DaemonHost()). Get("/v" + Docker.ClientVersion() + "/images/" + imageId + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). @@ -152,7 +152,7 @@ func TestRunOnce(t *testing.T) { gock.New(Docker.DaemonHost()). Get("/v" + Docker.ClientVersion() + "/images/" + imageId + "/json"). Reply(http.StatusOK). - JSON(types.ImageInspect{}) + JSON(image.InspectResponse{}) gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). @@ -236,7 +236,7 @@ func TestRunOnce(t *testing.T) { Reply(http.StatusOK) // Run test _, err = DockerRunOnce(context.Background(), imageId, nil, nil) - assert.ErrorContains(t, err, "request returned Service Unavailable for API route and version") + assert.ErrorContains(t, err, "request returned 503 Service Unavailable for API route and version") // Validate api assert.Empty(t, apitest.ListUnmatchedRequests()) }) @@ -259,7 +259,10 @@ func TestRunOnce(t *testing.T) { gock.New("http:///var/run/docker.sock"). Get("/v" + Docker.ClientVersion() + "/containers/" + containerId + "/json"). Reply(http.StatusOK). - JSON(types.ContainerJSONBase{State: &types.ContainerState{ExitCode: 1}}) + JSON(container.InspectResponse{ContainerJSONBase: &container.ContainerJSONBase{ + State: &container.State{ + ExitCode: 1, + }}}) gock.New(Docker.DaemonHost()). Delete("/v" + Docker.ClientVersion() + "/containers/" + containerId). Reply(http.StatusOK) @@ -293,7 +296,7 @@ func TestExecOnce(t *testing.T) { gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/containers/" + containerId + "/exec"). Reply(http.StatusAccepted). - JSON(types.IDResponse{ID: "test-command"}) + JSON(container.ExecCreateResponse{ID: "test-command"}) // Run test _, err := DockerExecOnce(context.Background(), containerId, nil, nil) assert.Error(t, err)