mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
cmd/dockerd: validate API configuration as part of --validate
Previously, the API server configuration would be initialized and validated when starting the API. Because of this, invalid configuration (e.g. missing or invalid TLS certificates) would not be detected when using `dockerd --validate`. This patch moves creation of the validation earlier, so that it's validated as part of `dockerd --validate`. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e16c3616e2
commit
0603f87fab
1 changed files with 5 additions and 4 deletions
|
@ -85,6 +85,11 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
serverConfig, err := newAPIServerConfig(cli.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.Validate {
|
||||
// If config wasn't OK we wouldn't have made it this far.
|
||||
fmt.Fprintln(os.Stderr, "configuration OK")
|
||||
|
@ -159,10 +164,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
serverConfig, err := newAPIServerConfig(cli.Config)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create API server")
|
||||
}
|
||||
cli.api = apiserver.New(serverConfig)
|
||||
|
||||
hosts, err := loadListeners(cli, serverConfig)
|
||||
|
|
Loading…
Reference in a new issue