Skip to content

Commit ac2726e

Browse files
committed
cmd/containerd: deduplicate config*.go
`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 <[email protected]>
1 parent 9a7ca39 commit ac2726e

4 files changed

Lines changed: 23 additions & 39 deletions

File tree

cmd/containerd/command/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323

2424
"github.com/BurntSushi/toml"
25+
"github.com/containerd/containerd/defaults"
2526
"github.com/containerd/containerd/pkg/timeout"
2627
"github.com/containerd/containerd/services/server"
2728
srvconfig "github.com/containerd/containerd/services/server/config"
@@ -113,3 +114,18 @@ var configCommand = cli.Command{
113114
},
114115
},
115116
}
117+
118+
func platformAgnosticDefaultConfig() *srvconfig.Config {
119+
return &srvconfig.Config{
120+
Version: 1,
121+
Root: defaults.DefaultRootDir,
122+
State: defaults.DefaultStateDir,
123+
GRPC: srvconfig.GRPCConfig{
124+
Address: defaults.DefaultAddress,
125+
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
126+
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
127+
},
128+
DisabledPlugins: []string{},
129+
RequiredPlugins: []string{},
130+
}
131+
}

cmd/containerd/command/config_linux.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,9 @@
1717
package command
1818

1919
import (
20-
"github.com/containerd/containerd/defaults"
2120
srvconfig "github.com/containerd/containerd/services/server/config"
2221
)
2322

2423
func defaultConfig() *srvconfig.Config {
25-
return &srvconfig.Config{
26-
Version: 1,
27-
Root: defaults.DefaultRootDir,
28-
State: defaults.DefaultStateDir,
29-
GRPC: srvconfig.GRPCConfig{
30-
Address: defaults.DefaultAddress,
31-
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
32-
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
33-
},
34-
DisabledPlugins: []string{},
35-
RequiredPlugins: []string{},
36-
}
24+
return platformAgnosticDefaultConfig()
3725
}

cmd/containerd/command/config_unsupported.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,10 @@ import (
2424
)
2525

2626
func defaultConfig() *srvconfig.Config {
27-
return &srvconfig.Config{
28-
Version: 1,
29-
Root: defaults.DefaultRootDir,
30-
State: defaults.DefaultStateDir,
31-
GRPC: srvconfig.GRPCConfig{
32-
Address: defaults.DefaultAddress,
33-
},
34-
Debug: srvconfig.Debug{
35-
Level: "info",
36-
Address: defaults.DefaultDebugAddress,
37-
},
38-
DisabledPlugins: []string{},
39-
RequiredPlugins: []string{},
27+
cfg := platformAgnosticDefaultConfig()
28+
cfg.Debug = srvconfig.Debug{
29+
Level: "info",
30+
Address: defaults.DefaultDebugAddress,
4031
}
32+
return cfg
4133
}

cmd/containerd/command/config_windows.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,9 @@
1717
package command
1818

1919
import (
20-
"github.com/containerd/containerd/defaults"
2120
srvconfig "github.com/containerd/containerd/services/server/config"
2221
)
2322

2423
func defaultConfig() *srvconfig.Config {
25-
return &srvconfig.Config{
26-
Version: 1,
27-
Root: defaults.DefaultRootDir,
28-
State: defaults.DefaultStateDir,
29-
GRPC: srvconfig.GRPCConfig{
30-
Address: defaults.DefaultAddress,
31-
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
32-
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,
33-
},
34-
DisabledPlugins: []string{},
35-
RequiredPlugins: []string{},
36-
}
24+
return platformAgnosticDefaultConfig()
3725
}

0 commit comments

Comments
 (0)