1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

api/types: move container-inspect types to api/types/container

This moves the `ContainerJSONBase`, `ContainerJSON` and `ContainerNode`
types to the api/types/container package and deprecates the old location.

- `ContainerJSONBase` was renamed to `InspectBase`
- `ContainerJSON` was rnamed to `InspectResponse`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-06-26 00:46:34 +02:00
parent 05b0e653dd
commit 1abc8f6158
18 changed files with 120 additions and 97 deletions

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/storage"
) )
// PruneReport contains the response for Engine API: // PruneReport contains the response for Engine API:
@ -90,7 +91,7 @@ type MountPoint struct {
} }
// State stores container's running state // State stores container's running state
// it's part of ContainerJSONBase and will return by "inspect" command // it's part of InspectBase and returned by "inspect" command
type State struct { type State struct {
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead" Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
Running bool Running bool
@ -128,3 +129,61 @@ type Summary struct {
NetworkSettings *NetworkSettingsSummary NetworkSettings *NetworkSettingsSummary
Mounts []MountPoint Mounts []MountPoint
} }
// ContainerNode stores information about the node that a container
// is running on. It's only used by the Docker Swarm standalone API.
//
// Deprecated: ContainerNode was used for the classic Docker Swarm standalone API. It will be removed in the next release.
type ContainerNode struct {
ID string
IPAddress string `json:"IP"`
Addr string
Name string
Cpus int
Memory int64
Labels map[string]string
}
// InspectBase contains response of Engine API GET "/containers/{name:.*}/json"
// for API version 1.18 and older.
//
// TODO(thaJeztah): combine InspectBase and InspectResponse into a single struct.
// The split between InspectBase (ContainerJSONBase) and InspectResponse (InspectResponse)
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
// held fields that were added in API 1.19 and up. Given that the minimum
// supported API version is now 1.24, we no longer use the separate type.
type InspectBase struct {
ID string `json:"Id"`
Created string
Path string
Args []string
State *State
Image string
ResolvConfPath string
HostnamePath string
HostsPath string
LogPath string
Node *ContainerNode `json:",omitempty"` // Deprecated: Node was only propagated by Docker Swarm standalone API. It sill be removed in the next release.
Name string
RestartCount int
Driver string
Platform string
MountLabel string
ProcessLabel string
AppArmorProfile string
ExecIDs []string
HostConfig *HostConfig
GraphDriver storage.DriverData
SizeRw *int64 `json:",omitempty"`
SizeRootFs *int64 `json:",omitempty"`
}
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
// endpoint.
type InspectResponse struct {
*InspectBase
Mounts []MountPoint
Config *Config
NetworkSettings *NetworkSettings
}

View File

@ -6,7 +6,6 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/storage"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
) )
@ -64,42 +63,6 @@ type Version struct {
BuildTime string `json:",omitempty"` BuildTime string `json:",omitempty"`
} }
// ContainerJSONBase contains response of Engine API:
// GET "/containers/{name:.*}/json"
type ContainerJSONBase struct {
ID string `json:"Id"`
Created string
Path string
Args []string
State *container.State
Image string
ResolvConfPath string
HostnamePath string
HostsPath string
LogPath string
Node *ContainerNode `json:",omitempty"` // Deprecated: Node was only propagated by Docker Swarm standalone API. It sill be removed in the next release.
Name string
RestartCount int
Driver string
Platform string
MountLabel string
ProcessLabel string
AppArmorProfile string
ExecIDs []string
HostConfig *container.HostConfig
GraphDriver storage.DriverData
SizeRw *int64 `json:",omitempty"`
SizeRootFs *int64 `json:",omitempty"`
}
// ContainerJSON is newly used struct along with MountPoint
type ContainerJSON struct {
*ContainerJSONBase
Mounts []container.MountPoint
Config *container.Config
NetworkSettings *container.NetworkSettings
}
// DiskUsageObject represents an object type used for disk usage query filtering. // DiskUsageObject represents an object type used for disk usage query filtering.
type DiskUsageObject string type DiskUsageObject string

View File

@ -196,19 +196,23 @@ type ImageImportSource image.ImportSource
// Deprecated: use [image.LoadResponse]. // Deprecated: use [image.LoadResponse].
type ImageLoadResponse = image.LoadResponse type ImageLoadResponse = image.LoadResponse
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
// for API version 1.18 and older.
//
// Deprecated: use [container.InspectResponse] or [container.InspectBase]. It will be removed in the next release.
type ContainerJSONBase = container.InspectBase
// ContainerJSON is the response for the GET "/containers/{name:.*}/json"
// endpoint.
//
// Deprecated: use [container.InspectResponse]. It will be removed in the next release.
type ContainerJSON = container.InspectResponse
// ContainerNode stores information about the node that a container // ContainerNode stores information about the node that a container
// is running on. It's only used by the Docker Swarm standalone API. // is running on. It's only used by the Docker Swarm standalone API.
// //
// Deprecated: ContainerNode was used for the classic Docker Swarm standalone API. It will be removed in the next release. // Deprecated: ContainerNode was used for the classic Docker Swarm standalone API. It will be removed in the next release.
type ContainerNode struct { type ContainerNode = container.ContainerNode //nolint:staticcheck // Ignore SA1019: container.ContainerNode is deprecated.
ID string
IPAddress string `json:"IP"`
Addr string
Name string
Cpus int
Memory int64
Labels map[string]string
}
// Container contains response of Engine API: // Container contains response of Engine API:
// GET "/containers/json" // GET "/containers/json"

View File

@ -7,29 +7,29 @@ import (
"io" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container"
) )
// ContainerInspect returns the container information. // ContainerInspect returns the container information.
func (cli *Client) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { func (cli *Client) ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error) {
if containerID == "" { if containerID == "" {
return types.ContainerJSON{}, objectNotFoundError{object: "container", id: containerID} return container.InspectResponse{}, objectNotFoundError{object: "container", id: containerID}
} }
serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", nil, nil) serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", nil, nil)
defer ensureReaderClosed(serverResp) defer ensureReaderClosed(serverResp)
if err != nil { if err != nil {
return types.ContainerJSON{}, err return container.InspectResponse{}, err
} }
var response types.ContainerJSON var response container.InspectResponse
err = json.NewDecoder(serverResp.body).Decode(&response) err = json.NewDecoder(serverResp.body).Decode(&response)
return response, err return response, err
} }
// ContainerInspectWithRaw returns the container information and its raw representation. // ContainerInspectWithRaw returns the container information and its raw representation.
func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (types.ContainerJSON, []byte, error) { func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (container.InspectResponse, []byte, error) {
if containerID == "" { if containerID == "" {
return types.ContainerJSON{}, nil, objectNotFoundError{object: "container", id: containerID} return container.InspectResponse{}, nil, objectNotFoundError{object: "container", id: containerID}
} }
query := url.Values{} query := url.Values{}
if getSize { if getSize {
@ -38,15 +38,15 @@ func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID stri
serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", query, nil) serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", query, nil)
defer ensureReaderClosed(serverResp) defer ensureReaderClosed(serverResp)
if err != nil { if err != nil {
return types.ContainerJSON{}, nil, err return container.InspectResponse{}, nil, err
} }
body, err := io.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return types.ContainerJSON{}, nil, err return container.InspectResponse{}, nil, err
} }
var response types.ContainerJSON var response container.InspectResponse
rdr := bytes.NewReader(body) rdr := bytes.NewReader(body)
err = json.NewDecoder(rdr).Decode(&response) err = json.NewDecoder(rdr).Decode(&response)
return response, body, err return response, body, err

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -52,8 +52,8 @@ func TestContainerInspect(t *testing.T) {
if !strings.HasPrefix(req.URL.Path, expectedURL) { if !strings.HasPrefix(req.URL.Path, expectedURL) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
} }
content, err := json.Marshal(types.ContainerJSON{ content, err := json.Marshal(container.InspectResponse{
ContainerJSONBase: &types.ContainerJSONBase{ InspectBase: &container.InspectBase{
ID: "container_id", ID: "container_id",
Image: "image", Image: "image",
Name: "name", Name: "name",

View File

@ -56,8 +56,8 @@ type ContainerAPIClient interface {
ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error
ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error
ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error)
ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (container.InspectResponse, []byte, error)
ContainerKill(ctx context.Context, container, signal string) error ContainerKill(ctx context.Context, container, signal string) error
ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error) ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error)

View File

@ -7,7 +7,6 @@ import (
"github.com/distribution/reference" "github.com/distribution/reference"
"github.com/docker/distribution" "github.com/docker/distribution"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
@ -45,7 +44,7 @@ type Backend interface {
ActivateContainerServiceBinding(containerName string) error ActivateContainerServiceBinding(containerName string) error
DeactivateContainerServiceBinding(containerName string) error DeactivateContainerServiceBinding(containerName string) error
UpdateContainerServiceConfig(containerName string, serviceConfig *clustertypes.ServiceConfig) error UpdateContainerServiceConfig(containerName string, serviceConfig *clustertypes.ServiceConfig) error
ContainerInspectCurrent(ctx context.Context, name string, size bool) (*types.ContainerJSON, error) ContainerInspectCurrent(ctx context.Context, name string, size bool) (*container.InspectResponse, error)
ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error) ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error)
ContainerRm(name string, config *backend.ContainerRmConfig) error ContainerRm(name string, config *backend.ContainerRmConfig) error
ContainerKill(name string, sig string) error ContainerKill(name string, sig string) error

View File

@ -13,7 +13,6 @@ import (
"github.com/containerd/log" "github.com/containerd/log"
"github.com/distribution/reference" "github.com/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
@ -372,13 +371,13 @@ func (c *containerAdapter) start(ctx context.Context) error {
return c.backend.ContainerStart(ctx, c.container.name(), "", "") return c.backend.ContainerStart(ctx, c.container.name(), "", "")
} }
func (c *containerAdapter) inspect(ctx context.Context) (types.ContainerJSON, error) { func (c *containerAdapter) inspect(ctx context.Context) (containertypes.InspectResponse, error) {
cs, err := c.backend.ContainerInspectCurrent(ctx, c.container.name(), false) cs, err := c.backend.ContainerInspectCurrent(ctx, c.container.name(), false)
if ctx.Err() != nil { if ctx.Err() != nil {
return types.ContainerJSON{}, ctx.Err() return containertypes.InspectResponse{}, ctx.Err()
} }
if err != nil { if err != nil {
return types.ContainerJSON{}, err return containertypes.InspectResponse{}, err
} }
return *cs, nil return *cs, nil
} }

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
executorpkg "github.com/docker/docker/daemon/cluster/executor" executorpkg "github.com/docker/docker/daemon/cluster/executor"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
@ -610,7 +610,7 @@ func (r *controller) checkClosed() error {
} }
} }
func parseContainerStatus(ctnr types.ContainerJSON) (*api.ContainerStatus, error) { func parseContainerStatus(ctnr container.InspectResponse) (*api.ContainerStatus, error) {
status := &api.ContainerStatus{ status := &api.ContainerStatus{
ContainerID: ctnr.ID, ContainerID: ctnr.ID,
PID: int32(ctnr.State.Pid), PID: int32(ctnr.State.Pid),
@ -620,7 +620,7 @@ func parseContainerStatus(ctnr types.ContainerJSON) (*api.ContainerStatus, error
return status, nil return status, nil
} }
func parsePortStatus(ctnr types.ContainerJSON) (*api.PortStatus, error) { func parsePortStatus(ctnr container.InspectResponse) (*api.PortStatus, error) {
status := &api.PortStatus{} status := &api.PortStatus{}
if ctnr.NetworkSettings != nil && len(ctnr.NetworkSettings.Ports) > 0 { if ctnr.NetworkSettings != nil && len(ctnr.NetworkSettings.Ports) > 0 {

View File

@ -9,7 +9,6 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
networktypes "github.com/docker/docker/api/types/network" networktypes "github.com/docker/docker/api/types/network"
@ -49,7 +48,7 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, size bo
// ContainerInspectCurrent returns low-level information about a // ContainerInspectCurrent returns low-level information about a
// container in a most recent api version. // container in a most recent api version.
func (daemon *Daemon) ContainerInspectCurrent(ctx context.Context, name string, size bool) (*types.ContainerJSON, error) { func (daemon *Daemon) ContainerInspectCurrent(ctx context.Context, name string, size bool) (*containertypes.InspectResponse, error) {
ctr, err := daemon.GetContainer(name) ctr, err := daemon.GetContainer(name)
if err != nil { if err != nil {
return nil, err return nil, err
@ -104,15 +103,15 @@ func (daemon *Daemon) ContainerInspectCurrent(ctx context.Context, name string,
base.SizeRootFs = &sizeRootFs base.SizeRootFs = &sizeRootFs
} }
return &types.ContainerJSON{ return &containertypes.InspectResponse{
ContainerJSONBase: base, InspectBase: base,
Mounts: mountPoints, Mounts: mountPoints,
Config: ctr.Config, Config: ctr.Config,
NetworkSettings: networkSettings, NetworkSettings: networkSettings,
}, nil }, nil
} }
func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *container.Container) (*types.ContainerJSONBase, error) { func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *container.Container) (*containertypes.InspectBase, error) {
// make a copy to play with // make a copy to play with
hostConfig := *container.HostConfig hostConfig := *container.HostConfig
@ -161,7 +160,7 @@ func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *contai
Health: containerHealth, Health: containerHealth,
} }
contJSONBase := &types.ContainerJSONBase{ contJSONBase := &containertypes.InspectBase{
ID: container.ID, ID: container.ID,
Created: container.Created.Format(time.RFC3339Nano), Created: container.Created.Format(time.RFC3339Nano),
Path: container.Path, Path: container.Path,

View File

@ -1,13 +1,13 @@
package daemon // import "github.com/docker/docker/daemon" package daemon // import "github.com/docker/docker/daemon"
import ( import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
"github.com/docker/docker/container" "github.com/docker/docker/api/types/container"
containerpkg "github.com/docker/docker/container"
) )
// This sets platform-specific fields // This sets platform-specific fields
func setPlatformSpecificContainerFields(container *container.Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase { func setPlatformSpecificContainerFields(container *containerpkg.Container, contJSONBase *container.InspectBase) *container.InspectBase {
contJSONBase.AppArmorProfile = container.AppArmorProfile contJSONBase.AppArmorProfile = container.AppArmorProfile
contJSONBase.ResolvConfPath = container.ResolvConfPath contJSONBase.ResolvConfPath = container.ResolvConfPath
contJSONBase.HostnamePath = container.HostnamePath contJSONBase.HostnamePath = container.HostnamePath
@ -16,7 +16,7 @@ func setPlatformSpecificContainerFields(container *container.Container, contJSON
return contJSONBase return contJSONBase
} }
func inspectExecProcessConfig(e *container.ExecConfig) *backend.ExecProcessConfig { func inspectExecProcessConfig(e *containerpkg.ExecConfig) *backend.ExecProcessConfig {
return &backend.ExecProcessConfig{ return &backend.ExecProcessConfig{
Tty: e.Tty, Tty: e.Tty,
Entrypoint: e.Entrypoint, Entrypoint: e.Entrypoint,

View File

@ -1,17 +1,17 @@
package daemon // import "github.com/docker/docker/daemon" package daemon // import "github.com/docker/docker/daemon"
import ( import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
"github.com/docker/docker/container" "github.com/docker/docker/api/types/container"
containerpkg "github.com/docker/docker/container"
) )
// This sets platform-specific fields // This sets platform-specific fields
func setPlatformSpecificContainerFields(container *container.Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase { func setPlatformSpecificContainerFields(container *containerpkg.Container, contJSONBase *container.InspectBase) *container.InspectBase {
return contJSONBase return contJSONBase
} }
func inspectExecProcessConfig(e *container.ExecConfig) *backend.ExecProcessConfig { func inspectExecProcessConfig(e *containerpkg.ExecConfig) *backend.ExecProcessConfig {
return &backend.ExecProcessConfig{ return &backend.ExecProcessConfig{
Tty: e.Tty, Tty: e.Tty,
Entrypoint: e.Entrypoint, Entrypoint: e.Entrypoint,

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/testutil" "github.com/docker/docker/testutil"
@ -98,7 +98,7 @@ func (s *DockerAPISuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) {
body := getInspectBody(c, "", containerID) body := getInspectBody(c, "", containerID)
var inspectJSON types.ContainerJSON var inspectJSON container.InspectResponse
err := json.Unmarshal(body, &inspectJSON) err := json.Unmarshal(body, &inspectJSON)
assert.NilError(c, err) assert.NilError(c, err)

View File

@ -14,7 +14,7 @@ import (
"testing" "testing"
"time" "time"
"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/network"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
@ -1017,7 +1017,7 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
// Current API version (API v1.21 and up) // Current API version (API v1.21 and up)
body := getInspectBody(c, "", id) body := getInspectBody(c, "", id)
var inspectCurrent types.ContainerJSON var inspectCurrent container.InspectResponse
err := json.Unmarshal(body, &inspectCurrent) err := json.Unmarshal(body, &inspectCurrent)
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, len(inspectCurrent.NetworkSettings.Networks), 3) assert.Equal(c, len(inspectCurrent.NetworkSettings.Networks), 3)

View File

@ -9,7 +9,6 @@ import (
"testing" "testing"
"time" "time"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
realcontainer "github.com/docker/docker/container" realcontainer "github.com/docker/docker/container"
@ -73,7 +72,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
assert.Check(t, err, "failed to start test container") assert.Check(t, err, "failed to start test container")
} }
func getContainerdShimPid(t *testing.T, c types.ContainerJSON) int { func getContainerdShimPid(t *testing.T, c containertypes.InspectResponse) int {
statB, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", c.State.Pid)) statB, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", c.State.Pid))
assert.Check(t, err, "error looking up containerd-shim pid") assert.Check(t, err, "error looking up containerd-shim pid")

View File

@ -162,7 +162,7 @@ func Remove(ctx context.Context, t *testing.T, apiClient client.APIClient, conta
assert.NilError(t, err) assert.NilError(t, err)
} }
func Inspect(ctx context.Context, t *testing.T, apiClient client.APIClient, containerRef string) types.ContainerJSON { func Inspect(ctx context.Context, t *testing.T, apiClient client.APIClient, containerRef string) container.InspectResponse {
t.Helper() t.Helper()
c, err := apiClient.ContainerInspect(ctx, containerRef) c, err := apiClient.ContainerInspect(ctx, containerRef)

View File

@ -64,7 +64,7 @@ func testServiceCreateInit(ctx context.Context, daemonEnabled bool) func(t *test
} }
} }
func inspectServiceContainer(ctx context.Context, t *testing.T, client client.APIClient, serviceID string) types.ContainerJSON { func inspectServiceContainer(ctx context.Context, t *testing.T, client client.APIClient, serviceID string) container.InspectResponse {
t.Helper() t.Helper()
containers, err := client.ContainerList(ctx, container.ListOptions{ containers, err := client.ContainerList(ctx, container.ListOptions{
Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.service.id="+serviceID)), Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.service.id="+serviceID)),

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
networktypes "github.com/docker/docker/api/types/network" networktypes "github.com/docker/docker/api/types/network"
swarmtypes "github.com/docker/docker/api/types/swarm" swarmtypes "github.com/docker/docker/api/types/swarm"
@ -324,7 +325,7 @@ func TestServiceUpdatePidsLimit(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
} }
func getServiceTaskContainer(ctx context.Context, t *testing.T, cli client.APIClient, serviceID string) types.ContainerJSON { func getServiceTaskContainer(ctx context.Context, t *testing.T, cli client.APIClient, serviceID string) container.InspectResponse {
t.Helper() t.Helper()
tasks, err := cli.TaskList(ctx, types.TaskListOptions{ tasks, err := cli.TaskList(ctx, types.TaskListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(