Skip to content

Commit

Permalink
cmd/containerd: deduplicate config*.go
Browse files Browse the repository at this point in the history
`config_linux.go` and `config_windows.go` are identical.

`config_unsupported.go` is also almost identical but enables debug logs by default.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Mar 15, 2021
1 parent 9a7ca39 commit ac2726e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 39 deletions.
16 changes: 16 additions & 0 deletions cmd/containerd/command/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"

"github.com/BurntSushi/toml"
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/pkg/timeout"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
Expand Down Expand Up @@ -113,3 +114,18 @@ var configCommand = cli.Command{
},
},
}

func platformAgnosticDefaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Version: 1,
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
},
DisabledPlugins: []string{},
RequiredPlugins: []string{},
}
}
14 changes: 1 addition & 13 deletions cmd/containerd/command/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,9 @@
package command

import (
"github.com/containerd/containerd/defaults"
srvconfig "github.com/containerd/containerd/services/server/config"
)

func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Version: 1,
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
},
DisabledPlugins: []string{},
RequiredPlugins: []string{},
}
return platformAgnosticDefaultConfig()
}
18 changes: 5 additions & 13 deletions cmd/containerd/command/config_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ import (
)

func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Version: 1,
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
},
Debug: srvconfig.Debug{
Level: "info",
Address: defaults.DefaultDebugAddress,
},
DisabledPlugins: []string{},
RequiredPlugins: []string{},
cfg := platformAgnosticDefaultConfig()
cfg.Debug = srvconfig.Debug{
Level: "info",
Address: defaults.DefaultDebugAddress,
}
return cfg
}
14 changes: 1 addition & 13 deletions cmd/containerd/command/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,9 @@
package command

import (
"github.com/containerd/containerd/defaults"
srvconfig "github.com/containerd/containerd/services/server/config"
)

func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Version: 1,
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
},
DisabledPlugins: []string{},
RequiredPlugins: []string{},
}
return platformAgnosticDefaultConfig()
}

0 comments on commit ac2726e

Please sign in to comment.