chore: update Docker API types to use new image package

This commit is contained in:
Jan Rundshagen 2025-03-29 12:39:57 +01:00 committed by Jan O. Rundshagen
parent d084f5604d
commit ca0d37a4ac
11 changed files with 89 additions and 978 deletions

View file

@ -9,9 +9,8 @@ import (
"github.com/beatkind/watchtower/pkg/filters"
t "github.com/beatkind/watchtower/pkg/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
dockerContainer "github.com/docker/docker/api/types/container"
cli "github.com/docker/docker/client"
"github.com/docker/docker/errdefs"
"github.com/onsi/gomega/gbytes"
@ -79,8 +78,8 @@ var _ = Describe("the client", func() {
When("removing a running container", func() {
When("the container still exist after stopping", func() {
It("should attempt to remove the container", func() {
container := MockContainer(WithContainerState(types.ContainerState{Running: true}))
containerStopped := MockContainer(WithContainerState(types.ContainerState{Running: false}))
container := MockContainer(WithContainerState(dockerContainer.State{Running: true}))
containerStopped := MockContainer(WithContainerState(dockerContainer.State{Running: false}))
cid := container.ContainerInfo().ID
mockServer.AppendHandlers(
@ -95,7 +94,7 @@ var _ = Describe("the client", func() {
})
When("the container does not exist after stopping", func() {
It("should not cause an error", func() {
container := MockContainer(WithContainerState(types.ContainerState{Running: true}))
container := MockContainer(WithContainerState(dockerContainer.State{Running: true}))
cid := container.ContainerInfo().ID
mockServer.AppendHandlers(
@ -271,7 +270,7 @@ var _ = Describe("the client", func() {
// API.ContainerExecCreate
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", HaveSuffix("containers/%v/exec", containerID)),
ghttp.VerifyJSONRepresenting(container.ExecOptions{
ghttp.VerifyJSONRepresenting(dockerContainer.ExecOptions{
User: user,
Detach: false,
Tty: true,
@ -281,12 +280,12 @@ var _ = Describe("the client", func() {
cmd,
},
}),
ghttp.RespondWithJSONEncoded(http.StatusOK, types.IDResponse{ID: execID}),
ghttp.RespondWithJSONEncoded(http.StatusOK, dockerContainer.CommitResponse{ID: execID}),
),
// API.ContainerExecStart
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", HaveSuffix("exec/%v/start", execID)),
ghttp.VerifyJSONRepresenting(container.ExecStartOptions{
ghttp.VerifyJSONRepresenting(dockerContainer.ExecStartOptions{
Detach: false,
Tty: true,
}),
@ -330,7 +329,7 @@ var _ = Describe("the client", func() {
endpoints := map[string]*network.EndpointSettings{
`test`: {Aliases: aliases},
}
container.containerInfo.NetworkSettings = &types.NetworkSettings{Networks: endpoints}
container.containerInfo.NetworkSettings = &dockerContainer.NetworkSettings{Networks: endpoints}
Expect(container.ContainerInfo().NetworkSettings.Networks[`test`].Aliases).To(Equal(aliases))
Expect(client.GetNetworkConfig(container).EndpointsConfig[`test`].Aliases).To(Equal([]string{"One", "Two", "Four"}))
})