This commit is contained in:
Vincent Batts 2017-01-16 23:16:43 +00:00 committed by GitHub
commit cfb6d9f71a
2 changed files with 32 additions and 0 deletions

View file

@ -175,6 +175,10 @@ func main() {
return err
}
if err := config.Check(); err != nil {
return err
}
cf := &logrus.TextFormatter{
TimestampFormat: "2006-01-02 15:04:05.000000000Z07:00",
FullTimestamp: true,

View file

@ -2,7 +2,9 @@ package server
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"github.com/BurntSushi/toml"
)
@ -169,3 +171,29 @@ func (c *Config) ToFile(path string) error {
return ioutil.WriteFile(path, w.Bytes(), 0644)
}
// Check resolves that all paths and files are available as expected
func (c *Config) Check() error {
for _, file := range []string{
c.RootConfig.SandboxDir,
c.RootConfig.ContainerDir,
c.RuntimeConfig.Runtime,
c.RuntimeConfig.Conmon,
c.RuntimeConfig.SeccompProfile,
c.ImageConfig.Pause,
} {
if _, err := os.Stat(file); err != nil && os.IsNotExist(err) {
return checkError{Path: file}
}
}
return nil
}
type checkError struct {
Path string
}
func (ce checkError) Error() string {
return fmt.Sprintf("%q does not exist", ce.Path)
}