mirror of
https://github.com/containrrr/watchtower.git
synced 2026-02-23 23:54:06 +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
|
|
@ -3,18 +3,19 @@ package mocks
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/onsi/ginkgo"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
t "github.com/beatkind/watchtower/pkg/types"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
I "github.com/docker/docker/api/types/image"
|
||||
dockerContainer "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
dockerImage "github.com/docker/docker/api/types/image"
|
||||
O "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
)
|
||||
|
|
@ -166,7 +167,7 @@ func getContainerHandler(containerId string, responseHandler http.HandlerFunc) h
|
|||
}
|
||||
|
||||
// GetContainerHandler mocks the GET containers/{id}/json endpoint
|
||||
func GetContainerHandler(containerID string, containerInfo *types.ContainerJSON) http.HandlerFunc {
|
||||
func GetContainerHandler(containerID string, containerInfo *dockerContainer.InspectResponse) http.HandlerFunc {
|
||||
responseHandler := containerNotFoundResponse(containerID)
|
||||
if containerInfo != nil {
|
||||
responseHandler = ghttp.RespondWithJSONEncoded(http.StatusOK, containerInfo)
|
||||
|
|
@ -175,7 +176,7 @@ func GetContainerHandler(containerID string, containerInfo *types.ContainerJSON)
|
|||
}
|
||||
|
||||
// GetImageHandler mocks the GET images/{id}/json endpoint
|
||||
func GetImageHandler(imageInfo *types.ImageInspect) http.HandlerFunc {
|
||||
func GetImageHandler(imageInfo *dockerImage.InspectResponse) http.HandlerFunc {
|
||||
return getImageHandler(t.ImageID(imageInfo.ID), ghttp.RespondWithJSONEncoded(http.StatusOK, imageInfo))
|
||||
}
|
||||
|
||||
|
|
@ -196,8 +197,8 @@ func ListContainersHandler(statuses ...string) http.HandlerFunc {
|
|||
func respondWithFilteredContainers(filters filters.Args) http.HandlerFunc {
|
||||
containersJSON, err := getMockJSONFile("./mocks/data/containers.json")
|
||||
O.ExpectWithOffset(2, err).ShouldNot(O.HaveOccurred())
|
||||
var filteredContainers []types.Container
|
||||
var containers []types.Container
|
||||
var filteredContainers []dockerContainer.Summary
|
||||
var containers []dockerContainer.Summary
|
||||
O.ExpectWithOffset(2, json.Unmarshal(containersJSON, &containers)).To(O.Succeed())
|
||||
for _, v := range containers {
|
||||
for _, key := range filters.Get("status") {
|
||||
|
|
@ -263,12 +264,12 @@ func RemoveImageHandler(imagesWithParents map[string][]string) http.HandlerFunc
|
|||
image := parts[len(parts)-1]
|
||||
|
||||
if parents, found := imagesWithParents[image]; found {
|
||||
items := []I.DeleteResponse{
|
||||
items := []dockerImage.DeleteResponse{
|
||||
{Untagged: image},
|
||||
{Deleted: image},
|
||||
}
|
||||
for _, parent := range parents {
|
||||
items = append(items, I.DeleteResponse{Deleted: parent})
|
||||
items = append(items, dockerImage.DeleteResponse{Deleted: parent})
|
||||
}
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, items)(w, r)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue