diff --git a/cmd/containerd/config.go b/cmd/containerd/config.go index b1ef45b..f219eb8 100644 --- a/cmd/containerd/config.go +++ b/cmd/containerd/config.go @@ -3,10 +3,27 @@ package main import ( "bytes" "io" + "os" "github.com/BurntSushi/toml" + "github.com/urfave/cli" ) +var configCommand = cli.Command{ + Name: "config", + Usage: "information on the containerd config", + Subcommands: []cli.Command{ + { + Name: "default", + Usage: "see the output of the default config", + Action: func(context *cli.Context) error { + _, err := conf.WriteTo(os.Stdout) + return err + }, + }, + }, +} + // loadConfig loads the config from the provided path func loadConfig(path string) error { md, err := toml.DecodeFile(path, conf) diff --git a/cmd/containerd/main.go b/cmd/containerd/main.go index c3f25d3..8377357 100644 --- a/cmd/containerd/main.go +++ b/cmd/containerd/main.go @@ -3,7 +3,6 @@ package main import ( _ "expvar" "fmt" - "io/ioutil" "net/http" _ "net/http/pprof" "os" @@ -82,6 +81,9 @@ func main() { Usage: "containerd root directory", }, } + app.Commands = []cli.Command{ + configCommand, + } app.Before = before app.Action = func(context *cli.Context) error { start := time.Now() @@ -152,19 +154,6 @@ func main() { } func before(context *cli.Context) error { - if context.GlobalString("config") == "default" { - fh, err := ioutil.TempFile("", "containerd-config.toml.") - if err != nil { - return err - } - if _, err := conf.WriteTo(fh); err != nil { - fh.Close() - return err - } - fh.Close() - log.G(global).Infof("containerd default config written to %q", fh.Name()) - os.Exit(0) - } err := loadConfig(context.GlobalString("config")) if err != nil && !os.IsNotExist(err) { return err