replace uses of deprecated api/types that moved to api/types/system

These types were moved to api/types/system:

- types.Info
- types.Commit
- types.PluginsInfo
- types.NetworkAddressPool
- types.Runtime
- types.SecurityOpt
- types/KeyValue
- types.DecodeSecurityOptions()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-07-14 23:42:40 +02:00
parent 1f87420b5b
commit 3469beb80d
22 changed files with 122 additions and 111 deletions

View File

@ -16,8 +16,8 @@ import (
"github.com/docker/cli/cli/debug"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/templates"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/registry"
"github.com/docker/go-units"
@ -40,7 +40,7 @@ type info struct {
// preserve backwards compatibility in the JSON rendering
// which has ServerInfo immediately within the top-level
// object.
*types.Info `json:",omitempty"`
*system.Info `json:",omitempty"`
ServerErrors []string `json:",omitempty"`
UserName string `json:"-"`
@ -86,7 +86,7 @@ func runInfo(cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error
clientVersion: newClientVersion(dockerCli.CurrentContext(), nil),
Debug: debug.IsEnabled(),
},
Info: &types.Info{},
Info: &system.Info{},
}
if plugins, err := pluginmanager.ListPlugins(dockerCli, cmd.Root()); err == nil {
info.ClientInfo.Plugins = plugins
@ -267,7 +267,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error {
for _, ci := range []struct {
Name string
Commit types.Commit
Commit system.Commit
}{
{"containerd", info.ContainerdCommit},
{"runc", info.RuncCommit},
@ -280,7 +280,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error {
fprintln(output)
}
if len(info.SecurityOptions) != 0 {
if kvs, err := types.DecodeSecurityOptions(info.SecurityOptions); err != nil {
if kvs, err := system.DecodeSecurityOptions(info.SecurityOptions); err != nil {
errs = append(errs, err)
} else {
fprintln(output, " Security Options:")
@ -377,7 +377,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error {
}
//nolint:gocyclo
func printSwarmInfo(output io.Writer, info types.Info) {
func printSwarmInfo(output io.Writer, info system.Info) {
if info.Swarm.LocalNodeState == swarm.LocalNodeStateInactive || info.Swarm.LocalNodeState == swarm.LocalNodeStateLocked {
return
}
@ -464,11 +464,11 @@ func printServerWarnings(stdErr io.Writer, info *info) {
// info.Warnings. This function is used to provide backward compatibility with
// daemons that do not provide these warnings. No new warnings should be added
// here.
func printSecurityOptionsWarnings(stdErr io.Writer, info types.Info) {
func printSecurityOptionsWarnings(stdErr io.Writer, info system.Info) {
if info.OSType == "windows" {
return
}
kvs, _ := types.DecodeSecurityOptions(info.SecurityOptions)
kvs, _ := system.DecodeSecurityOptions(info.SecurityOptions)
for _, so := range kvs {
if so.Name != "seccomp" {
continue
@ -486,7 +486,7 @@ func printSecurityOptionsWarnings(stdErr io.Writer, info types.Info) {
// info.Warnings. This function is used to provide backward compatibility with
// daemons that do not provide these warnings. No new warnings should be added
// here.
func printServerWarningsLegacy(stdErr io.Writer, info types.Info) {
func printServerWarningsLegacy(stdErr io.Writer, info system.Info) {
if info.OSType == "windows" {
return
}

View File

@ -8,9 +8,9 @@ import (
pluginmanager "github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@ -24,7 +24,7 @@ func base64Decode(val string) []byte {
const sampleID = "EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX"
var sampleInfoNoSwarm = types.Info{
var sampleInfoNoSwarm = system.Info{
ID: sampleID,
Containers: 0,
ContainersRunning: 0,
@ -39,7 +39,7 @@ var sampleInfoNoSwarm = types.Info{
{"Native Overlay Diff", "true"},
},
SystemStatus: nil,
Plugins: types.PluginsInfo{
Plugins: system.PluginsInfo{
Volume: []string{"local"},
Network: []string{"bridge", "host", "macvlan", "null", "overlay"},
Authorization: nil,
@ -98,7 +98,7 @@ var sampleInfoNoSwarm = types.Info{
Labels: []string{"provider=digitalocean"},
ExperimentalBuild: false,
ServerVersion: "17.06.1-ce",
Runtimes: map[string]types.Runtime{
Runtimes: map[string]system.Runtime{
"runc": {
Path: "docker-runc",
Args: nil,
@ -109,20 +109,20 @@ var sampleInfoNoSwarm = types.Info{
LiveRestoreEnabled: false,
Isolation: "",
InitBinary: "docker-init",
ContainerdCommit: types.Commit{
ContainerdCommit: system.Commit{
ID: "6e23458c129b551d5c9871e5174f6b1b7f6d1170",
Expected: "6e23458c129b551d5c9871e5174f6b1b7f6d1170",
},
RuncCommit: types.Commit{
RuncCommit: system.Commit{
ID: "810190ceaa507aa2727d7ae6f4790c76ec150bd2",
Expected: "810190ceaa507aa2727d7ae6f4790c76ec150bd2",
},
InitCommit: types.Commit{
InitCommit: system.Commit{
ID: "949e6fa",
Expected: "949e6fa",
},
SecurityOptions: []string{"name=apparmor", "name=seccomp,profile=default"},
DefaultAddressPools: []types.NetworkAddressPool{
DefaultAddressPools: []system.NetworkAddressPool{
{
Base: "10.123.0.0/16",
Size: 24,