api/types: move system info types to api/types/system

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-03 13:14:14 +02:00
parent 98d3da79ef
commit c90229ed9a
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
24 changed files with 329 additions and 260 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
) )
// DiskUsageOptions holds parameters for system disk usage query. // DiskUsageOptions holds parameters for system disk usage query.
@ -26,7 +27,7 @@ type DiskUsageOptions struct {
// Backend is the methods that need to be implemented to provide // Backend is the methods that need to be implemented to provide
// system specific functionality. // system specific functionality.
type Backend interface { type Backend interface {
SystemInfo() *types.Info SystemInfo() *system.Info
SystemVersion() types.Version SystemVersion() types.Version
SystemDiskUsage(ctx context.Context, opts DiskUsageOptions) (*types.DiskUsage, error) SystemDiskUsage(ctx context.Context, opts DiskUsageOptions) (*types.DiskUsage, error)
SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{}) SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{})

View file

@ -2,7 +2,7 @@ package system // import "github.com/docker/docker/api/server/router/system"
import ( import (
"github.com/docker/docker/api/server/router" "github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/system"
buildkit "github.com/docker/docker/builder/builder-next" buildkit "github.com/docker/docker/builder/builder-next"
"resenje.org/singleflight" "resenje.org/singleflight"
) )
@ -19,7 +19,7 @@ type systemRouter struct {
// collectSystemInfo is a single-flight for the /info endpoint, // collectSystemInfo is a single-flight for the /info endpoint,
// unique per API version (as different API versions may return // unique per API version (as different API versions may return
// a different API response). // a different API response).
collectSystemInfo singleflight.Group[string, *types.Info] collectSystemInfo singleflight.Group[string, *system.Info]
} }
// NewRouter initializes a new system router // NewRouter initializes a new system router

View file

@ -15,6 +15,7 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
timetypes "github.com/docker/docker/api/types/time" timetypes "github.com/docker/docker/api/types/time"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
@ -58,7 +59,7 @@ func (s *systemRouter) swarmStatus() string {
func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
version := httputils.VersionFromContext(ctx) version := httputils.VersionFromContext(ctx)
info, _, _ := s.collectSystemInfo.Do(ctx, version, func(ctx context.Context) (*types.Info, error) { info, _, _ := s.collectSystemInfo.Do(ctx, version, func(ctx context.Context) (*system.Info, error) {
info := s.backend.SystemInfo() info := s.backend.SystemInfo()
if s.cluster != nil { if s.cluster != nil {
@ -68,7 +69,7 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
if versions.LessThan(version, "1.25") { if versions.LessThan(version, "1.25") {
// TODO: handle this conversion in engine-api // TODO: handle this conversion in engine-api
kvSecOpts, err := types.DecodeSecurityOptions(info.SecurityOptions) kvSecOpts, err := system.DecodeSecurityOptions(info.SecurityOptions)
if err != nil { if err != nil {
info.Warnings = append(info.Warnings, err.Error()) info.Warnings = append(info.Warnings, err.Error())
} }

115
api/types/system/info.go Normal file
View file

@ -0,0 +1,115 @@
package system
import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm"
)
// Info contains response of Engine API:
// GET "/info"
type Info struct {
ID string
Containers int
ContainersRunning int
ContainersPaused int
ContainersStopped int
Images int
Driver string
DriverStatus [][2]string
SystemStatus [][2]string `json:",omitempty"` // SystemStatus is only propagated by the Swarm standalone API
Plugins PluginsInfo
MemoryLimit bool
SwapLimit bool
KernelMemory bool `json:",omitempty"` // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
KernelMemoryTCP bool `json:",omitempty"` // KernelMemoryTCP is not supported on cgroups v2.
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
CPUCfsQuota bool `json:"CpuCfsQuota"`
CPUShares bool
CPUSet bool
PidsLimit bool
IPv4Forwarding bool
BridgeNfIptables bool
BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
Debug bool
NFd int
OomKillDisable bool
NGoroutines int
SystemTime string
LoggingDriver string
CgroupDriver string
CgroupVersion string `json:",omitempty"`
NEventsListener int
KernelVersion string
OperatingSystem string
OSVersion string
OSType string
Architecture string
IndexServerAddress string
RegistryConfig *registry.ServiceConfig
NCPU int
MemTotal int64
GenericResources []swarm.GenericResource
DockerRootDir string
HTTPProxy string `json:"HttpProxy"`
HTTPSProxy string `json:"HttpsProxy"`
NoProxy string
Name string
Labels []string
ExperimentalBuild bool
ServerVersion string
Runtimes map[string]Runtime
DefaultRuntime string
Swarm swarm.Info
// LiveRestoreEnabled determines whether containers should be kept
// running when the daemon is shutdown or upon daemon start if
// running containers are detected
LiveRestoreEnabled bool
Isolation container.Isolation
InitBinary string
ContainerdCommit Commit
RuncCommit Commit
InitCommit Commit
SecurityOptions []string
ProductLicense string `json:",omitempty"`
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
// Legacy API fields for older API versions.
legacyFields
// Warnings contains a slice of warnings that occurred while collecting
// system information. These warnings are intended to be informational
// messages for the user, and are not intended to be parsed / used for
// other purposes, as they do not have a fixed format.
Warnings []string
}
type legacyFields struct {
ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions.
}
// PluginsInfo is a temp struct holding Plugins name
// registered with docker daemon. It is used by [Info] struct
type PluginsInfo struct {
// List of Volume plugins registered
Volume []string
// List of Network plugins registered
Network []string
// List of Authorization plugins registered
Authorization []string
// List of Log plugins registered
Log []string
}
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
// in the version-string of external tools, such as containerd, or runC.
type Commit struct {
ID string // ID is the actual commit ID of external tool.
Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time.
}
// NetworkAddressPool is a temp struct used by [Info] struct.
type NetworkAddressPool struct {
Base string
Size int
}

View file

@ -0,0 +1,14 @@
package system
// Runtime describes an OCI runtime
type Runtime struct {
// "Legacy" runtime configuration for runc-compatible runtimes.
Path string `json:"path,omitempty"`
Args []string `json:"runtimeArgs,omitempty"`
// Shimv2 runtime configuration. Mutually exclusive with the legacy config above.
Type string `json:"runtimeType,omitempty"`
Options map[string]interface{} `json:"options,omitempty"`
}

View file

@ -0,0 +1,48 @@
package system
import (
"errors"
"fmt"
"strings"
)
// SecurityOpt contains the name and options of a security option
type SecurityOpt struct {
Name string
Options []KeyValue
}
// DecodeSecurityOptions decodes a security options string slice to a
// type-safe [SecurityOpt].
func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) {
so := []SecurityOpt{}
for _, opt := range opts {
// support output from a < 1.13 docker daemon
if !strings.Contains(opt, "=") {
so = append(so, SecurityOpt{Name: opt})
continue
}
secopt := SecurityOpt{}
for _, s := range strings.Split(opt, ",") {
k, v, ok := strings.Cut(s, "=")
if !ok {
return nil, fmt.Errorf("invalid security option %q", s)
}
if k == "" || v == "" {
return nil, errors.New("invalid empty security option")
}
if k == "name" {
secopt.Name = v
continue
}
secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v})
}
so = append(so, secopt)
}
return so, nil
}
// KeyValue holds a key/value pair.
type KeyValue struct {
Key, Value string
}

View file

@ -1,18 +1,14 @@
package types // import "github.com/docker/docker/api/types" package types // import "github.com/docker/docker/api/types"
import ( import (
"errors"
"fmt"
"io" "io"
"os" "os"
"strings"
"time" "time"
"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/mount" "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry"
"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"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
@ -232,155 +228,6 @@ type Version struct {
BuildTime string `json:",omitempty"` BuildTime string `json:",omitempty"`
} }
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
// in the version-string of external tools, such as containerd, or runC.
type Commit struct {
ID string // ID is the actual commit ID of external tool.
Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time.
}
// Info contains response of Engine API:
// GET "/info"
type Info struct {
ID string
Containers int
ContainersRunning int
ContainersPaused int
ContainersStopped int
Images int
Driver string
DriverStatus [][2]string
SystemStatus [][2]string `json:",omitempty"` // SystemStatus is only propagated by the Swarm standalone API
Plugins PluginsInfo
MemoryLimit bool
SwapLimit bool
KernelMemory bool `json:",omitempty"` // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
KernelMemoryTCP bool `json:",omitempty"` // KernelMemoryTCP is not supported on cgroups v2.
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
CPUCfsQuota bool `json:"CpuCfsQuota"`
CPUShares bool
CPUSet bool
PidsLimit bool
IPv4Forwarding bool
BridgeNfIptables bool
BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
Debug bool
NFd int
OomKillDisable bool
NGoroutines int
SystemTime string
LoggingDriver string
CgroupDriver string
CgroupVersion string `json:",omitempty"`
NEventsListener int
KernelVersion string
OperatingSystem string
OSVersion string
OSType string
Architecture string
IndexServerAddress string
RegistryConfig *registry.ServiceConfig
NCPU int
MemTotal int64
GenericResources []swarm.GenericResource
DockerRootDir string
HTTPProxy string `json:"HttpProxy"`
HTTPSProxy string `json:"HttpsProxy"`
NoProxy string
Name string
Labels []string
ExperimentalBuild bool
ServerVersion string
Runtimes map[string]Runtime
DefaultRuntime string
Swarm swarm.Info
// LiveRestoreEnabled determines whether containers should be kept
// running when the daemon is shutdown or upon daemon start if
// running containers are detected
LiveRestoreEnabled bool
Isolation container.Isolation
InitBinary string
ContainerdCommit Commit
RuncCommit Commit
InitCommit Commit
SecurityOptions []string
ProductLicense string `json:",omitempty"`
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
// Legacy API fields for older API versions.
legacyFields
// Warnings contains a slice of warnings that occurred while collecting
// system information. These warnings are intended to be informational
// messages for the user, and are not intended to be parsed / used for
// other purposes, as they do not have a fixed format.
Warnings []string
}
type legacyFields struct {
ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions.
}
// KeyValue holds a key/value pair
type KeyValue struct {
Key, Value string
}
// NetworkAddressPool is a temp struct used by Info struct
type NetworkAddressPool struct {
Base string
Size int
}
// SecurityOpt contains the name and options of a security option
type SecurityOpt struct {
Name string
Options []KeyValue
}
// DecodeSecurityOptions decodes a security options string slice to a type safe
// SecurityOpt
func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) {
so := []SecurityOpt{}
for _, opt := range opts {
// support output from a < 1.13 docker daemon
if !strings.Contains(opt, "=") {
so = append(so, SecurityOpt{Name: opt})
continue
}
secopt := SecurityOpt{}
for _, s := range strings.Split(opt, ",") {
k, v, ok := strings.Cut(s, "=")
if !ok {
return nil, fmt.Errorf("invalid security option %q", s)
}
if k == "" || v == "" {
return nil, errors.New("invalid empty security option")
}
if k == "name" {
secopt.Name = v
continue
}
secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v})
}
so = append(so, secopt)
}
return so, nil
}
// PluginsInfo is a temp struct holding Plugins name
// registered with docker daemon. It is used by Info struct
type PluginsInfo struct {
// List of Volume plugins registered
Volume []string
// List of Network plugins registered
Network []string
// List of Authorization plugins registered
Authorization []string
// List of Log plugins registered
Log []string
}
// ExecStartCheck is a temp struct used by execStart // ExecStartCheck is a temp struct used by execStart
// Config fields is part of ExecConfig in runconfig package // Config fields is part of ExecConfig in runconfig package
type ExecStartCheck struct { type ExecStartCheck struct {
@ -652,19 +499,6 @@ type Checkpoint struct {
Name string // Name is the name of the checkpoint Name string // Name is the name of the checkpoint
} }
// Runtime describes an OCI runtime
type Runtime struct {
// "Legacy" runtime configuration for runc-compatible runtimes.
Path string `json:"path,omitempty"`
Args []string `json:"runtimeArgs,omitempty"`
// Shimv2 runtime configuration. Mutually exclusive with the legacy config above.
Type string `json:"runtimeType,omitempty"`
Options map[string]interface{} `json:"options,omitempty"`
}
// 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

@ -0,0 +1,49 @@
package types
import "github.com/docker/docker/api/types/system"
// Info contains response of Engine API:
// GET "/info"
//
// Deprecated: use [system.Info].
type Info = system.Info
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
// in the version-string of external tools, such as containerd, or runC.
//
// Deprecated: use [system.Commit].
type Commit = system.Commit
// PluginsInfo is a temp struct holding Plugins name
// registered with docker daemon. It is used by [system.Info] struct
//
// Deprecated: use [system.PluginsInfo].
type PluginsInfo = system.PluginsInfo
// NetworkAddressPool is a temp struct used by [system.Info] struct.
//
// Deprecated: use [system.NetworkAddressPool].
type NetworkAddressPool = system.NetworkAddressPool
// Runtime describes an OCI runtime.
//
// Deprecated: use [system.Runtime].
type Runtime = system.Runtime
// SecurityOpt contains the name and options of a security option.
//
// Deprecated: use [system.SecurityOpt].
type SecurityOpt = system.SecurityOpt
// KeyValue holds a key/value pair.
//
// Deprecated: use [system.KeyValue].
type KeyValue = system.KeyValue
// DecodeSecurityOptions decodes a security options string slice to a type safe
// [system.SecurityOpt].
//
// Deprecated: use [system.DecodeSecurityOptions].
func DecodeSecurityOptions(opts []string) ([]system.SecurityOpt, error) {
return system.DecodeSecurityOptions(opts)
}

View file

@ -6,12 +6,12 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/system"
) )
// Info returns information about the docker server. // Info returns information about the docker server.
func (cli *Client) Info(ctx context.Context) (types.Info, error) { func (cli *Client) Info(ctx context.Context) (system.Info, error) {
var info types.Info var info system.Info
serverResp, err := cli.get(ctx, "/info", url.Values{}, nil) serverResp, err := cli.get(ctx, "/info", url.Values{}, nil)
defer ensureReaderClosed(serverResp) defer ensureReaderClosed(serverResp)
if err != nil { if err != nil {

View file

@ -10,7 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/system"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -46,7 +46,7 @@ func TestInfo(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)
} }
info := &types.Info{ info := &system.Info{
ID: "daemonID", ID: "daemonID",
Containers: 3, Containers: 3,
} }

View file

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
@ -165,7 +166,7 @@ type SwarmAPIClient interface {
// SystemAPIClient defines API client methods for the system // SystemAPIClient defines API client methods for the system
type SystemAPIClient interface { type SystemAPIClient interface {
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
Info(ctx context.Context) (types.Info, error) Info(ctx context.Context) (system.Info, error)
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)
Ping(ctx context.Context) (types.Ping, error) Ping(ctx context.Context) (types.Ping, error)

View file

@ -16,6 +16,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
containerpkg "github.com/docker/docker/container" containerpkg "github.com/docker/docker/container"
clustertypes "github.com/docker/docker/daemon/cluster/provider" clustertypes "github.com/docker/docker/daemon/cluster/provider"
@ -52,7 +53,7 @@ type Backend interface {
SetContainerDependencyStore(name string, store exec.DependencyGetter) error SetContainerDependencyStore(name string, store exec.DependencyGetter) error
SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error
SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error
SystemInfo() *types.Info SystemInfo() *system.Info
Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error)
SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error
DaemonJoinsCluster(provider cluster.Provider) DaemonJoinsCluster(provider cluster.Provider)

View file

@ -7,8 +7,8 @@ import (
"path/filepath" "path/filepath"
"github.com/containerd/cgroups/v3" "github.com/containerd/cgroups/v3"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
"github.com/docker/docker/pkg/homedir" "github.com/docker/docker/pkg/homedir"
"github.com/docker/docker/pkg/rootless" "github.com/docker/docker/pkg/rootless"
@ -61,22 +61,22 @@ type Config struct {
CommonConfig CommonConfig
// Fields below here are platform specific. // Fields below here are platform specific.
Runtimes map[string]types.Runtime `json:"runtimes,omitempty"` Runtimes map[string]system.Runtime `json:"runtimes,omitempty"`
DefaultInitBinary string `json:"default-init,omitempty"` DefaultInitBinary string `json:"default-init,omitempty"`
CgroupParent string `json:"cgroup-parent,omitempty"` CgroupParent string `json:"cgroup-parent,omitempty"`
EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"` EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"`
RemappedRoot string `json:"userns-remap,omitempty"` RemappedRoot string `json:"userns-remap,omitempty"`
Ulimits map[string]*units.Ulimit `json:"default-ulimits,omitempty"` Ulimits map[string]*units.Ulimit `json:"default-ulimits,omitempty"`
CPURealtimePeriod int64 `json:"cpu-rt-period,omitempty"` CPURealtimePeriod int64 `json:"cpu-rt-period,omitempty"`
CPURealtimeRuntime int64 `json:"cpu-rt-runtime,omitempty"` CPURealtimeRuntime int64 `json:"cpu-rt-runtime,omitempty"`
OOMScoreAdjust int `json:"oom-score-adjust,omitempty"` // Deprecated: configure the daemon's oom-score-adjust using a process manager instead. OOMScoreAdjust int `json:"oom-score-adjust,omitempty"` // Deprecated: configure the daemon's oom-score-adjust using a process manager instead.
Init bool `json:"init,omitempty"` Init bool `json:"init,omitempty"`
InitPath string `json:"init-path,omitempty"` InitPath string `json:"init-path,omitempty"`
SeccompProfile string `json:"seccomp-profile,omitempty"` SeccompProfile string `json:"seccomp-profile,omitempty"`
ShmSize opts.MemBytes `json:"default-shm-size,omitempty"` ShmSize opts.MemBytes `json:"default-shm-size,omitempty"`
NoNewPrivileges bool `json:"no-new-privileges,omitempty"` NoNewPrivileges bool `json:"no-new-privileges,omitempty"`
IpcMode string `json:"default-ipc-mode,omitempty"` IpcMode string `json:"default-ipc-mode,omitempty"`
CgroupNamespaceMode string `json:"default-cgroupns-mode,omitempty"` CgroupNamespaceMode string `json:"default-cgroupns-mode,omitempty"`
// ResolvConf is the path to the configuration of the host resolver // ResolvConf is the path to the configuration of the host resolver
ResolvConf string `json:"resolv-conf,omitempty"` ResolvConf string `json:"resolv-conf,omitempty"`
Rootless bool `json:"rootless,omitempty"` Rootless bool `json:"rootless,omitempty"`
@ -184,7 +184,7 @@ func setPlatformDefaults(cfg *Config) error {
cfg.ShmSize = opts.MemBytes(DefaultShmSize) cfg.ShmSize = opts.MemBytes(DefaultShmSize)
cfg.SeccompProfile = SeccompProfileDefault cfg.SeccompProfile = SeccompProfileDefault
cfg.IpcMode = string(DefaultIpcMode) cfg.IpcMode = string(DefaultIpcMode)
cfg.Runtimes = make(map[string]types.Runtime) cfg.Runtimes = make(map[string]system.Runtime)
if cgroups.Mode() != cgroups.Unified { if cgroups.Mode() != cgroups.Unified {
cfg.CgroupNamespaceMode = string(DefaultCgroupV1NamespaceMode) cfg.CgroupNamespaceMode = string(DefaultCgroupV1NamespaceMode)

View file

@ -11,6 +11,7 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/docker/docker/api" "github.com/docker/docker/api"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/cli/debug" "github.com/docker/docker/cli/debug"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
"github.com/docker/docker/daemon/logger" "github.com/docker/docker/daemon/logger"
@ -27,13 +28,13 @@ import (
) )
// SystemInfo returns information about the host server the daemon is running on. // SystemInfo returns information about the host server the daemon is running on.
func (daemon *Daemon) SystemInfo() *types.Info { func (daemon *Daemon) SystemInfo() *system.Info {
defer metrics.StartTimer(hostInfoFunctions.WithValues("system_info"))() defer metrics.StartTimer(hostInfoFunctions.WithValues("system_info"))()
sysInfo := daemon.RawSysInfo() sysInfo := daemon.RawSysInfo()
cfg := daemon.config() cfg := daemon.config()
v := &types.Info{ v := &system.Info{
ID: daemon.id, ID: daemon.id,
Images: daemon.imageService.CountImages(), Images: daemon.imageService.CountImages(),
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
@ -122,7 +123,7 @@ func (daemon *Daemon) SystemVersion() types.Version {
return v return v
} }
func (daemon *Daemon) fillDriverInfo(v *types.Info) { func (daemon *Daemon) fillDriverInfo(v *system.Info) {
v.Driver = daemon.imageService.StorageDriver() v.Driver = daemon.imageService.StorageDriver()
v.DriverStatus = daemon.imageService.LayerStoreStatus() v.DriverStatus = daemon.imageService.LayerStoreStatus()
@ -138,8 +139,8 @@ WARNING: The %s storage-driver is deprecated, and will be removed in a future re
fillDriverWarnings(v) fillDriverWarnings(v)
} }
func (daemon *Daemon) fillPluginsInfo(v *types.Info, cfg *config.Config) { func (daemon *Daemon) fillPluginsInfo(v *system.Info, cfg *config.Config) {
v.Plugins = types.PluginsInfo{ v.Plugins = system.PluginsInfo{
Volume: daemon.volumes.GetDriverList(), Volume: daemon.volumes.GetDriverList(),
Network: daemon.GetNetworkDriverList(), Network: daemon.GetNetworkDriverList(),
@ -150,7 +151,7 @@ func (daemon *Daemon) fillPluginsInfo(v *types.Info, cfg *config.Config) {
} }
} }
func (daemon *Daemon) fillSecurityOptions(v *types.Info, sysInfo *sysinfo.SysInfo, cfg *config.Config) { func (daemon *Daemon) fillSecurityOptions(v *system.Info, sysInfo *sysinfo.SysInfo, cfg *config.Config) {
var securityOptions []string var securityOptions []string
if sysInfo.AppArmor { if sysInfo.AppArmor {
securityOptions = append(securityOptions, "name=apparmor") securityOptions = append(securityOptions, "name=apparmor")
@ -180,7 +181,7 @@ func (daemon *Daemon) fillSecurityOptions(v *types.Info, sysInfo *sysinfo.SysInf
v.SecurityOptions = securityOptions v.SecurityOptions = securityOptions
} }
func (daemon *Daemon) fillContainerStates(v *types.Info) { func (daemon *Daemon) fillContainerStates(v *system.Info) {
cRunning, cPaused, cStopped := stateCtr.get() cRunning, cPaused, cStopped := stateCtr.get()
v.Containers = cRunning + cPaused + cStopped v.Containers = cRunning + cPaused + cStopped
v.ContainersPaused = cPaused v.ContainersPaused = cPaused
@ -196,14 +197,14 @@ func (daemon *Daemon) fillContainerStates(v *types.Info) {
// this information optional (cli to request "with debugging information"), or // this information optional (cli to request "with debugging information"), or
// only collect it if the daemon has debug enabled. For the CLI code, see // only collect it if the daemon has debug enabled. For the CLI code, see
// https://github.com/docker/cli/blob/v20.10.12/cli/command/system/info.go#L239-L244 // https://github.com/docker/cli/blob/v20.10.12/cli/command/system/info.go#L239-L244
func (daemon *Daemon) fillDebugInfo(v *types.Info) { func (daemon *Daemon) fillDebugInfo(v *system.Info) {
v.Debug = debug.IsEnabled() v.Debug = debug.IsEnabled()
v.NFd = fileutils.GetTotalUsedFds() v.NFd = fileutils.GetTotalUsedFds()
v.NGoroutines = runtime.NumGoroutine() v.NGoroutines = runtime.NumGoroutine()
v.NEventsListener = daemon.EventsService.SubscribersCount() v.NEventsListener = daemon.EventsService.SubscribersCount()
} }
func (daemon *Daemon) fillAPIInfo(v *types.Info, cfg *config.Config) { func (daemon *Daemon) fillAPIInfo(v *system.Info, cfg *config.Config) {
const warn string = ` const warn string = `
Access to the remote API is equivalent to root access on the host. Refer Access to the remote API is equivalent to root access on the host. Refer
to the 'Docker daemon attack surface' section in the documentation for to the 'Docker daemon attack surface' section in the documentation for
@ -226,9 +227,9 @@ func (daemon *Daemon) fillAPIInfo(v *types.Info, cfg *config.Config) {
} }
} }
func (daemon *Daemon) fillDefaultAddressPools(v *types.Info, cfg *config.Config) { func (daemon *Daemon) fillDefaultAddressPools(v *system.Info, cfg *config.Config) {
for _, pool := range cfg.DefaultAddressPools.Value() { for _, pool := range cfg.DefaultAddressPools.Value() {
v.DefaultAddressPools = append(v.DefaultAddressPools, types.NetworkAddressPool{ v.DefaultAddressPools = append(v.DefaultAddressPools, system.NetworkAddressPool{
Base: pool.Base, Base: pool.Base,
Size: pool.Size, Size: pool.Size,
}) })

View file

@ -14,6 +14,7 @@ import (
v2runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" v2runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/docker/docker/api/types" "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/system"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
"github.com/docker/docker/pkg/rootless" "github.com/docker/docker/pkg/rootless"
"github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/sysinfo"
@ -22,7 +23,7 @@ import (
) )
// fillPlatformInfo fills the platform related info. // fillPlatformInfo fills the platform related info.
func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) { func (daemon *Daemon) fillPlatformInfo(v *system.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) {
v.CgroupDriver = cgroupDriver(&cfg.Config) v.CgroupDriver = cgroupDriver(&cfg.Config)
v.CgroupVersion = "1" v.CgroupVersion = "1"
if sysInfo.CgroupUnified { if sysInfo.CgroupUnified {
@ -41,12 +42,12 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo,
v.CPUSet = sysInfo.Cpuset v.CPUSet = sysInfo.Cpuset
v.PidsLimit = sysInfo.PidsLimit v.PidsLimit = sysInfo.PidsLimit
} }
v.Runtimes = make(map[string]types.Runtime) v.Runtimes = make(map[string]system.Runtime)
for n, p := range stockRuntimes() { for n, p := range stockRuntimes() {
v.Runtimes[n] = types.Runtime{Path: p} v.Runtimes[n] = system.Runtime{Path: p}
} }
for n, r := range cfg.Config.Runtimes { for n, r := range cfg.Config.Runtimes {
v.Runtimes[n] = types.Runtime{ v.Runtimes[n] = system.Runtime{
Path: r.Path, Path: r.Path,
Args: append([]string(nil), r.Args...), Args: append([]string(nil), r.Args...),
} }
@ -280,7 +281,7 @@ func getRootlessKitClient() (rkclient.Client, error) {
return rkclient.New(apiSock) return rkclient.New(apiSock)
} }
func fillDriverWarnings(v *types.Info) { func fillDriverWarnings(v *system.Info) {
for _, pair := range v.DriverStatus { for _, pair := range v.DriverStatus {
if pair[0] == "Extended file attributes" && pair[1] == "best-effort" { if pair[0] == "Extended file attributes" && pair[1] == "best-effort" {
msg := fmt.Sprintf("WARNING: %s: extended file attributes from container images "+ msg := fmt.Sprintf("WARNING: %s: extended file attributes from container images "+

View file

@ -2,17 +2,18 @@ package daemon // import "github.com/docker/docker/daemon"
import ( import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
"github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/sysinfo"
) )
// fillPlatformInfo fills the platform related info. // fillPlatformInfo fills the platform related info.
func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) { func (daemon *Daemon) fillPlatformInfo(v *system.Info, sysInfo *sysinfo.SysInfo, cfg *configStore) {
} }
func (daemon *Daemon) fillPlatformVersion(v *types.Version, cfg *configStore) {} func (daemon *Daemon) fillPlatformVersion(v *types.Version, cfg *configStore) {}
func fillDriverWarnings(v *types.Info) { func fillDriverWarnings(v *system.Info) {
} }
func cgroupNamespacesEnabled(sysInfo *sysinfo.SysInfo, cfg *config.Config) bool { func cgroupNamespacesEnabled(sysInfo *sysinfo.SysInfo, cfg *config.Config) bool {

View file

@ -1,10 +1,10 @@
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/system"
"github.com/docker/docker/dockerversion" "github.com/docker/docker/dockerversion"
) )
func (daemon *Daemon) fillLicense(v *types.Info) { func (daemon *Daemon) fillLicense(v *system.Info) {
v.ProductLicense = dockerversion.DefaultProductLicense v.ProductLicense = dockerversion.DefaultProductLicense
} }

View file

@ -3,13 +3,13 @@ package daemon // import "github.com/docker/docker/daemon"
import ( import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/system"
"github.com/docker/docker/dockerversion" "github.com/docker/docker/dockerversion"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
func TestFillLicense(t *testing.T) { func TestFillLicense(t *testing.T) {
v := &types.Info{} v := &system.Info{}
d := &Daemon{ d := &Daemon{
root: "/var/lib/docker/", root: "/var/lib/docker/",
} }

View file

@ -11,13 +11,12 @@ import (
runtimeoptions_v1 "github.com/containerd/containerd/pkg/runtimeoptions/v1" runtimeoptions_v1 "github.com/containerd/containerd/pkg/runtimeoptions/v1"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
v2runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" v2runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/errdefs"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"github.com/docker/docker/api/types"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/errdefs"
) )
func TestSetupRuntimes(t *testing.T) { func TestSetupRuntimes(t *testing.T) {
@ -29,7 +28,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "Empty", name: "Empty",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {}, "myruntime": {},
}, },
}, },
@ -38,7 +37,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "ArgsOnly", name: "ArgsOnly",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {Args: []string{"foo", "bar"}}, "myruntime": {Args: []string{"foo", "bar"}},
}, },
}, },
@ -47,7 +46,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "OptionsOnly", name: "OptionsOnly",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {Options: map[string]interface{}{"hello": "world"}}, "myruntime": {Options: map[string]interface{}{"hello": "world"}},
}, },
}, },
@ -56,7 +55,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "PathAndType", name: "PathAndType",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {Path: "/bin/true", Type: "io.containerd.runsc.v1"}, "myruntime": {Path: "/bin/true", Type: "io.containerd.runsc.v1"},
}, },
}, },
@ -65,7 +64,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "PathAndOptions", name: "PathAndOptions",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {Path: "/bin/true", Options: map[string]interface{}{"a": "b"}}, "myruntime": {Path: "/bin/true", Options: map[string]interface{}{"a": "b"}},
}, },
}, },
@ -74,7 +73,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "TypeAndArgs", name: "TypeAndArgs",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": {Type: "io.containerd.runsc.v1", Args: []string{"--version"}}, "myruntime": {Type: "io.containerd.runsc.v1", Args: []string{"--version"}},
}, },
}, },
@ -83,7 +82,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "PathArgsOptions", name: "PathArgsOptions",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": { "myruntime": {
Path: "/bin/true", Path: "/bin/true",
Args: []string{"--version"}, Args: []string{"--version"},
@ -96,7 +95,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "TypeOptionsArgs", name: "TypeOptionsArgs",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": { "myruntime": {
Type: "io.containerd.kata.v2", Type: "io.containerd.kata.v2",
Options: map[string]interface{}{"a": "b"}, Options: map[string]interface{}{"a": "b"},
@ -109,7 +108,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "PathArgsTypeOptions", name: "PathArgsTypeOptions",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myruntime": { "myruntime": {
Path: "/bin/true", Path: "/bin/true",
Args: []string{"foo"}, Args: []string{"foo"},
@ -123,7 +122,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "CannotOverrideStockRuntime", name: "CannotOverrideStockRuntime",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
config.StockRuntimeName: {}, config.StockRuntimeName: {},
}, },
}, },
@ -157,7 +156,7 @@ func TestSetupRuntimes(t *testing.T) {
{ {
name: "SetDefinedRuntimeAsDefault", name: "SetDefinedRuntimeAsDefault",
config: &config.Config{ config: &config.Config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"some-runtime": { "some-runtime": {
Path: "/usr/local/bin/file-not-found", Path: "/usr/local/bin/file-not-found",
}, },
@ -192,30 +191,30 @@ func TestGetRuntime(t *testing.T) {
// which would not be allowed as implicit runtime names. Explicit takes // which would not be allowed as implicit runtime names. Explicit takes
// precedence over implicit. // precedence over implicit.
const configuredRtName = "my/custom.runtime.v1" const configuredRtName = "my/custom.runtime.v1"
configuredRuntime := types.Runtime{Path: "/bin/true"} configuredRuntime := system.Runtime{Path: "/bin/true"}
const rtWithArgsName = "withargs" const rtWithArgsName = "withargs"
rtWithArgs := types.Runtime{ rtWithArgs := system.Runtime{
Path: "/bin/false", Path: "/bin/false",
Args: []string{"--version"}, Args: []string{"--version"},
} }
const shimWithOptsName = "shimwithopts" const shimWithOptsName = "shimwithopts"
shimWithOpts := types.Runtime{ shimWithOpts := system.Runtime{
Type: plugin.RuntimeRuncV2, Type: plugin.RuntimeRuncV2,
Options: map[string]interface{}{"IoUid": 42}, Options: map[string]interface{}{"IoUid": 42},
} }
const shimAliasName = "wasmedge" const shimAliasName = "wasmedge"
shimAlias := types.Runtime{Type: "io.containerd.wasmedge.v1"} shimAlias := system.Runtime{Type: "io.containerd.wasmedge.v1"}
const configuredShimByPathName = "shimwithpath" const configuredShimByPathName = "shimwithpath"
configuredShimByPath := types.Runtime{Type: "/path/to/my/shim"} configuredShimByPath := system.Runtime{Type: "/path/to/my/shim"}
// A runtime configured with the generic 'runtimeoptions/v1.Options' shim configuration options. // A runtime configured with the generic 'runtimeoptions/v1.Options' shim configuration options.
// https://gvisor.dev/docs/user_guide/containerd/configuration/#:~:text=to%20the%20shim.-,Containerd%201.3%2B,-Starting%20in%201.3 // https://gvisor.dev/docs/user_guide/containerd/configuration/#:~:text=to%20the%20shim.-,Containerd%201.3%2B,-Starting%20in%201.3
const gvisorName = "gvisor" const gvisorName = "gvisor"
gvisorRuntime := types.Runtime{ gvisorRuntime := system.Runtime{
Type: "io.containerd.runsc.v1", Type: "io.containerd.runsc.v1",
Options: map[string]interface{}{ Options: map[string]interface{}{
"TypeUrl": "io.containerd.runsc.v1.options", "TypeUrl": "io.containerd.runsc.v1.options",
@ -227,7 +226,7 @@ func TestGetRuntime(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
cfg.Root = t.TempDir() cfg.Root = t.TempDir()
cfg.Runtimes = map[string]types.Runtime{ cfg.Runtimes = map[string]system.Runtime{
configuredRtName: configuredRuntime, configuredRtName: configuredRuntime,
rtWithArgsName: rtWithArgs, rtWithArgsName: rtWithArgs,
shimWithOptsName: shimWithOpts, shimWithOptsName: shimWithOpts,
@ -363,7 +362,7 @@ func TestGetRuntime_PreflightCheck(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
cfg.Root = t.TempDir() cfg.Root = t.TempDir()
cfg.Runtimes = map[string]types.Runtime{ cfg.Runtimes = map[string]system.Runtime{
"path-only": { "path-only": {
Path: "/usr/local/bin/file-not-found", Path: "/usr/local/bin/file-not-found",
}, },
@ -393,7 +392,7 @@ func TestRuntimeWrapping(t *testing.T) {
cfg, err := config.New() cfg, err := config.New()
assert.NilError(t, err) assert.NilError(t, err)
cfg.Root = t.TempDir() cfg.Root = t.TempDir()
cfg.Runtimes = map[string]types.Runtime{ cfg.Runtimes = map[string]system.Runtime{
"change-args": { "change-args": {
Path: "/bin/true", Path: "/bin/true",
Args: []string{"foo", "bar"}, Args: []string{"foo", "bar"},
@ -431,15 +430,15 @@ func TestRuntimeWrapping(t *testing.T) {
} }
} }
cfg.Runtimes["change-args"] = types.Runtime{ cfg.Runtimes["change-args"] = system.Runtime{
Path: cfg.Runtimes["change-args"].Path, Path: cfg.Runtimes["change-args"].Path,
Args: []string{"baz", "quux"}, Args: []string{"baz", "quux"},
} }
cfg.Runtimes["change-path"] = types.Runtime{ cfg.Runtimes["change-path"] = system.Runtime{
Path: "/bin/false", Path: "/bin/false",
Args: cfg.Runtimes["change-path"].Args, Args: cfg.Runtimes["change-path"].Args,
} }
cfg.Runtimes["drop-args"] = types.Runtime{ cfg.Runtimes["drop-args"] = system.Runtime{
Path: cfg.Runtimes["drop-args"].Path, Path: cfg.Runtimes["drop-args"].Path,
} }
delete(cfg.Runtimes, "goes-away") delete(cfg.Runtimes, "goes-away")

View file

@ -14,6 +14,7 @@ import (
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/testutil/request" "github.com/docker/docker/testutil/request"
@ -71,7 +72,7 @@ func (s *DockerAPISuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T)
getGoRoutines := func() int { getGoRoutines := func() int {
_, body, err := request.Get("/info") _, body, err := request.Get("/info")
assert.NilError(c, err) assert.NilError(c, err)
info := types.Info{} info := system.Info{}
err = json.NewDecoder(body).Decode(&info) err = json.NewDecoder(body).Decode(&info)
assert.NilError(c, err) assert.NilError(c, err)
body.Close() body.Close()

View file

@ -18,6 +18,7 @@ import (
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry" registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/testutil/daemon" "github.com/docker/docker/testutil/daemon"
"github.com/docker/docker/testutil/fixtures/plugin" "github.com/docker/docker/testutil/fixtures/plugin"
@ -234,11 +235,11 @@ func TestPluginsWithRuntimes(t *testing.T) {
assert.NilError(t, os.WriteFile(p, []byte(script), 0o777)) assert.NilError(t, os.WriteFile(p, []byte(script), 0o777))
type config struct { type config struct {
Runtimes map[string]types.Runtime `json:"runtimes"` Runtimes map[string]system.Runtime `json:"runtimes"`
} }
cfg, err := json.Marshal(config{ cfg, err := json.Marshal(config{
Runtimes: map[string]types.Runtime{ Runtimes: map[string]system.Runtime{
"myrt": {Path: p}, "myrt": {Path: p},
"myrtArgs": {Path: p, Args: []string{"someArg"}}, "myrtArgs": {Path: p, Args: []string{"someArg"}},
}, },

View file

@ -4,20 +4,20 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/system"
) )
// RuntimeOpt defines a map of Runtimes // RuntimeOpt defines a map of Runtimes
type RuntimeOpt struct { type RuntimeOpt struct {
name string name string
stockRuntimeName string stockRuntimeName string
values *map[string]types.Runtime values *map[string]system.Runtime
} }
// NewNamedRuntimeOpt creates a new RuntimeOpt // NewNamedRuntimeOpt creates a new RuntimeOpt
func NewNamedRuntimeOpt(name string, ref *map[string]types.Runtime, stockRuntime string) *RuntimeOpt { func NewNamedRuntimeOpt(name string, ref *map[string]system.Runtime, stockRuntime string) *RuntimeOpt {
if ref == nil { if ref == nil {
ref = &map[string]types.Runtime{} ref = &map[string]system.Runtime{}
} }
return &RuntimeOpt{name: name, values: ref, stockRuntimeName: stockRuntime} return &RuntimeOpt{name: name, values: ref, stockRuntimeName: stockRuntime}
} }
@ -51,7 +51,7 @@ func (o *RuntimeOpt) Set(val string) error {
return fmt.Errorf("runtime '%s' was already defined", k) return fmt.Errorf("runtime '%s' was already defined", k)
} }
(*o.values)[k] = types.Runtime{Path: v} (*o.values)[k] = system.Runtime{Path: v}
return nil return nil
} }
@ -67,12 +67,12 @@ func (o *RuntimeOpt) String() string {
} }
// GetMap returns a map of Runtimes (name: path) // GetMap returns a map of Runtimes (name: path)
func (o *RuntimeOpt) GetMap() map[string]types.Runtime { func (o *RuntimeOpt) GetMap() map[string]system.Runtime {
if o.values != nil { if o.values != nil {
return *o.values return *o.values
} }
return map[string]types.Runtime{} return map[string]system.Runtime{}
} }
// Type returns the type of the option // Type returns the type of the option

View file

@ -13,8 +13,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/container" "github.com/docker/docker/container"
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
@ -90,7 +90,7 @@ type Daemon struct {
DataPathPort uint32 DataPathPort uint32
OOMScoreAdjust int OOMScoreAdjust int
// cached information // cached information
CachedInfo types.Info CachedInfo system.Info
} }
// NewDaemon returns a Daemon instance to be used for testing. // NewDaemon returns a Daemon instance to be used for testing.
@ -817,7 +817,7 @@ func (d *Daemon) queryRootDir() (string, error) {
} }
// Info returns the info struct for this daemon // Info returns the info struct for this daemon
func (d *Daemon) Info(t testing.TB) types.Info { func (d *Daemon) Info(t testing.TB) system.Info {
t.Helper() t.Helper()
c := d.NewClientT(t) c := d.NewClientT(t)
info, err := c.Info(context.Background()) info, err := c.Info(context.Background())

View file

@ -10,6 +10,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/testutil/fixtures/load" "github.com/docker/docker/testutil/fixtures/load"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -20,7 +21,7 @@ import (
// under test // under test
type Execution struct { type Execution struct {
client client.APIClient client client.APIClient
DaemonInfo types.Info DaemonInfo system.Info
PlatformDefaults PlatformDefaults PlatformDefaults PlatformDefaults
protectedElements protectedElements protectedElements protectedElements
} }
@ -57,7 +58,7 @@ func FromClient(c *client.Client) (*Execution, error) {
}, nil }, nil
} }
func getPlatformDefaults(info types.Info) PlatformDefaults { func getPlatformDefaults(info system.Info) PlatformDefaults {
volumesPath := filepath.Join(info.DockerRootDir, "volumes") volumesPath := filepath.Join(info.DockerRootDir, "volumes")
containersPath := filepath.Join(info.DockerRootDir, "containers") containersPath := filepath.Join(info.DockerRootDir, "containers")