containerd: make a config subcommand

For the purpose of reviewing the default config

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2017-04-10 14:14:10 -04:00
parent bb9f908cdf
commit 741c471753
Signed by: vbatts
GPG key ID: 10937E57733F1362
2 changed files with 20 additions and 14 deletions

View file

@ -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