mirror of
https://github.com/containrrr/watchtower.git
synced 2026-03-11 15:12:35 +01:00
chore: update Docker API types to use new image package
This commit is contained in:
parent
d084f5604d
commit
ca0d37a4ac
11 changed files with 89 additions and 978 deletions
|
|
@ -8,15 +8,15 @@ import (
|
|||
|
||||
"github.com/beatkind/watchtower/pkg/container"
|
||||
wt "github.com/beatkind/watchtower/pkg/types"
|
||||
"github.com/docker/docker/api/types"
|
||||
dockerContainer "github.com/docker/docker/api/types/container"
|
||||
dockerImage "github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
// CreateMockContainer creates a container substitute valid for testing
|
||||
func CreateMockContainer(id string, name string, image string, created time.Time) wt.Container {
|
||||
content := types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
content := dockerContainer.InspectResponse{
|
||||
ContainerJSONBase: &dockerContainer.ContainerJSONBase{
|
||||
ID: id,
|
||||
Image: image,
|
||||
Name: name,
|
||||
|
|
@ -38,24 +38,24 @@ func CreateMockContainer(id string, name string, image string, created time.Time
|
|||
}
|
||||
|
||||
// CreateMockImageInfo returns a mock image info struct based on the passed image
|
||||
func CreateMockImageInfo(image string) *types.ImageInspect {
|
||||
return &types.ImageInspect{
|
||||
ID: image,
|
||||
RepoDigests: []string{
|
||||
image,
|
||||
},
|
||||
}
|
||||
func CreateMockImageInfo(image string) *dockerImage.InspectResponse {
|
||||
return &dockerImage.InspectResponse{
|
||||
ID: image,
|
||||
RepoTags: []string{
|
||||
image,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CreateMockContainerWithImageInfo should only be used for testing
|
||||
func CreateMockContainerWithImageInfo(id string, name string, image string, created time.Time, imageInfo types.ImageInspect) wt.Container {
|
||||
func CreateMockContainerWithImageInfo(id string, name string, image string, created time.Time, imageInfo dockerImage.InspectResponse) wt.Container {
|
||||
return CreateMockContainerWithImageInfoP(id, name, image, created, &imageInfo)
|
||||
}
|
||||
|
||||
// CreateMockContainerWithImageInfoP should only be used for testing
|
||||
func CreateMockContainerWithImageInfoP(id string, name string, image string, created time.Time, imageInfo *types.ImageInspect) wt.Container {
|
||||
content := types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
func CreateMockContainerWithImageInfoP(id string, name string, image string, created time.Time, imageInfo *dockerImage.InspectResponse) wt.Container {
|
||||
content := dockerContainer.InspectResponse{
|
||||
ContainerJSONBase: &dockerContainer.ContainerJSONBase{
|
||||
ID: id,
|
||||
Image: image,
|
||||
Name: name,
|
||||
|
|
@ -81,12 +81,12 @@ func CreateMockContainerWithDigest(id string, name string, image string, created
|
|||
|
||||
// CreateMockContainerWithConfig creates a container substitute valid for testing
|
||||
func CreateMockContainerWithConfig(id string, name string, image string, running bool, restarting bool, created time.Time, config *dockerContainer.Config) wt.Container {
|
||||
content := types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
content := dockerContainer.InspectResponse{
|
||||
ContainerJSONBase: &dockerContainer.ContainerJSONBase{
|
||||
ID: id,
|
||||
Image: image,
|
||||
Name: name,
|
||||
State: &types.ContainerState{
|
||||
State: &dockerContainer.State{
|
||||
Running: running,
|
||||
Restarting: restarting,
|
||||
},
|
||||
|
|
@ -120,9 +120,9 @@ func CreateContainerForProgress(index int, idPrefix int, nameFormat string) (wt.
|
|||
}
|
||||
|
||||
// CreateMockContainerWithLinks should only be used for testing
|
||||
func CreateMockContainerWithLinks(id string, name string, image string, created time.Time, links []string, imageInfo *types.ImageInspect) wt.Container {
|
||||
content := types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
func CreateMockContainerWithLinks(id string, name string, image string, created time.Time, links []string, imageInfo *dockerImage.InspectResponse) wt.Container {
|
||||
content := dockerContainer.InspectResponse{
|
||||
ContainerJSONBase: &dockerContainer.ContainerJSONBase{
|
||||
ID: id,
|
||||
Image: image,
|
||||
Name: name,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
"github.com/beatkind/watchtower/internal/actions"
|
||||
"github.com/beatkind/watchtower/pkg/types"
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
dockerContainer "github.com/docker/docker/api/types/container"
|
||||
dockerImage "github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/go-connections/nat"
|
||||
|
||||
. "github.com/beatkind/watchtower/internal/actions/mocks"
|
||||
|
|
@ -44,7 +44,7 @@ func getLinkedTestData(withImageInfo bool) *TestData {
|
|||
"fake-image1:latest",
|
||||
time.Now().AddDate(0, 0, -1))
|
||||
|
||||
var imageInfo *dockerTypes.ImageInspect
|
||||
var imageInfo *dockerImage.InspectResponse
|
||||
if withImageInfo {
|
||||
imageInfo = CreateMockImageInfo("test-container-02")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue