mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: update docker and compose Go dependencies to the latest versions
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-units"
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
type Container struct {
|
||||
types.ContainerJSON
|
||||
container.InspectResponse
|
||||
// created caches the parsed creation time by CreatedTime.
|
||||
created time.Time
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func (c *Container) Healthy() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
return c.State.Health.Status == types.Healthy
|
||||
return c.State.Health.Status == container.Healthy
|
||||
}
|
||||
|
||||
// HumanState returns a human-readable description of the container's state. Based on the Docker implementation:
|
||||
@@ -78,7 +78,7 @@ func (c *Container) HumanState() (string, error) {
|
||||
|
||||
if c.State.Health != nil {
|
||||
status := c.State.Health.Status
|
||||
if status == types.Starting {
|
||||
if status == container.Starting {
|
||||
status = "health: " + status
|
||||
}
|
||||
|
||||
|
||||
+30
-31
@@ -4,7 +4,6 @@ import (
|
||||
"net/netip"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -15,9 +14,9 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("exited", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Running: false,
|
||||
Dead: false,
|
||||
ExitCode: 0,
|
||||
@@ -29,9 +28,9 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("running with no health check", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Running: true,
|
||||
},
|
||||
},
|
||||
@@ -41,12 +40,12 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("running and healthy", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Running: true,
|
||||
Health: &types.Health{
|
||||
Status: types.Healthy,
|
||||
Health: &container.Health{
|
||||
Status: container.Healthy,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -56,12 +55,12 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("running but unhealthy", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Running: true,
|
||||
Health: &types.Health{
|
||||
Status: types.Unhealthy,
|
||||
Health: &container.Health{
|
||||
Status: container.Unhealthy,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -71,11 +70,11 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("running with health starting", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Running: true,
|
||||
Health: &types.Health{
|
||||
Health: &container.Health{
|
||||
Status: "starting",
|
||||
},
|
||||
},
|
||||
@@ -86,9 +85,9 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("dead", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Dead: true,
|
||||
Running: false,
|
||||
},
|
||||
@@ -99,9 +98,9 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("restarting", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Restarting: true,
|
||||
Running: true,
|
||||
ExitCode: 1,
|
||||
@@ -113,9 +112,9 @@ func TestContainer_Healthy(t *testing.T) {
|
||||
|
||||
t.Run("paused", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &Container{ContainerJSON: types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
State: &types.ContainerState{
|
||||
c := &Container{InspectResponse: container.InspectResponse{
|
||||
ContainerJSONBase: &container.ContainerJSONBase{
|
||||
State: &container.State{
|
||||
Paused: true,
|
||||
Running: true,
|
||||
},
|
||||
@@ -280,7 +279,7 @@ func TestContainer_ConflictingServicePorts(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctr := &ServiceContainer{Container: Container{ContainerJSON: types.ContainerJSON{
|
||||
ctr := &ServiceContainer{Container: Container{InspectResponse: container.InspectResponse{
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
LabelServicePorts: tt.containerPorts,
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
|
||||
type MachineImage struct {
|
||||
Metadata *pb.Metadata
|
||||
Image types.ImageInspect
|
||||
Image image.InspectResponse
|
||||
}
|
||||
|
||||
// MachineImages represents images present on a particular machine.
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestConfigSpecsFromCompose(t *testing.T) {
|
||||
{
|
||||
Source: "nginx-config",
|
||||
Target: "/etc/nginx/nginx.conf",
|
||||
Mode: func() *uint32 { m := uint32(0o644); return &m }(),
|
||||
Mode: func() *types.FileMode { m := types.FileMode(0o644); return &m }(),
|
||||
},
|
||||
},
|
||||
expectedSpecs: []api.ConfigSpec{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package compose
|
||||
|
||||
// TODO: make compose, cli, and api packages public.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
@@ -68,7 +68,7 @@ func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.Ser
|
||||
}
|
||||
|
||||
if machines, ok := service.Extensions[MachinesExtensionKey].(MachinesSource); ok {
|
||||
spec.Placement.Machines = []string(machines)
|
||||
spec.Placement.Machines = machines
|
||||
}
|
||||
|
||||
// Map LogDriver if specified
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/compose/v2/pkg/progress"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/psviderski/uncloud/internal/docker"
|
||||
machinedocker "github.com/psviderski/uncloud/internal/machine/docker"
|
||||
@@ -64,7 +64,7 @@ func (cli *Client) CreateContainer(
|
||||
}
|
||||
|
||||
// NotFound (No such image) error is expected if the image is missing.
|
||||
if !dockerclient.IsErrNotFound(err) || !strings.Contains(err.Error(), "No such image") {
|
||||
if !errdefs.IsNotFound(err) || !strings.Contains(err.Error(), "No such image") {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/compose/v2/pkg/progress"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
@@ -32,7 +33,7 @@ import (
|
||||
|
||||
func (cli *Client) InspectImage(ctx context.Context, id string) ([]api.MachineImage, error) {
|
||||
images, err := cli.Docker.InspectImage(ctx, id)
|
||||
if dockerclient.IsErrNotFound(err) {
|
||||
if errdefs.IsNotFound(err) {
|
||||
err = api.ErrNotFound
|
||||
}
|
||||
|
||||
@@ -123,8 +124,8 @@ func (cli *Client) PushImage(ctx context.Context, image string, opts PushImageOp
|
||||
defer dockerCli.Close()
|
||||
|
||||
// Check if Docker image exists locally.
|
||||
if _, _, err = dockerCli.ImageInspectWithRaw(ctx, image); err != nil {
|
||||
if dockerclient.IsErrNotFound(err) {
|
||||
if _, err = dockerCli.ImageInspect(ctx, image); err != nil {
|
||||
if errdefs.IsNotFound(err) {
|
||||
return fmt.Errorf("image '%s' not found locally", image)
|
||||
}
|
||||
return fmt.Errorf("inspect image '%s' locally: %w", image, err)
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/docker/compose/v2/pkg/progress"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
||||
"github.com/psviderski/uncloud/pkg/api"
|
||||
)
|
||||
@@ -123,7 +123,7 @@ func (cli *Client) RemoveVolume(ctx context.Context, machineNameOrID, volumeName
|
||||
pw.Event(progress.RemovingEvent(eventID))
|
||||
|
||||
if err = cli.Docker.RemoveVolume(ctx, volumeName, force); err != nil {
|
||||
if dockerclient.IsErrNotFound(err) {
|
||||
if errdefs.IsNotFound(err) {
|
||||
return api.ErrNotFound
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user