1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

cmd/dockerd: change newAPIServerConfig() to only receive config.Config

This function took the whole daemon cli as argument but only needed the config

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-04-21 10:25:50 +02:00
parent 57c20c1b79
commit e16c3616e2
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -159,7 +159,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
} }
} }
serverConfig, err := newAPIServerConfig(cli) serverConfig, err := newAPIServerConfig(cli.Config)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to create API server") return errors.Wrap(err, "failed to create API server")
} }
@ -605,28 +605,28 @@ func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error)
return opts, nil return opts, nil
} }
func newAPIServerConfig(cli *DaemonCli) (*apiserver.Config, error) { func newAPIServerConfig(config *config.Config) (*apiserver.Config, error) {
serverConfig := &apiserver.Config{ serverConfig := &apiserver.Config{
SocketGroup: cli.Config.SocketGroup, SocketGroup: config.SocketGroup,
Version: dockerversion.Version, Version: dockerversion.Version,
CorsHeaders: cli.Config.CorsHeaders, CorsHeaders: config.CorsHeaders,
} }
if cli.Config.TLS != nil && *cli.Config.TLS { if config.TLS != nil && *config.TLS {
tlsOptions := tlsconfig.Options{ tlsOptions := tlsconfig.Options{
CAFile: cli.Config.CommonTLSOptions.CAFile, CAFile: config.CommonTLSOptions.CAFile,
CertFile: cli.Config.CommonTLSOptions.CertFile, CertFile: config.CommonTLSOptions.CertFile,
KeyFile: cli.Config.CommonTLSOptions.KeyFile, KeyFile: config.CommonTLSOptions.KeyFile,
ExclusiveRootPools: true, ExclusiveRootPools: true,
} }
if cli.Config.TLSVerify == nil || *cli.Config.TLSVerify { if config.TLSVerify == nil || *config.TLSVerify {
// server requires and verifies client's certificate // server requires and verifies client's certificate
tlsOptions.ClientAuth = tls.RequireAndVerifyClientCert tlsOptions.ClientAuth = tls.RequireAndVerifyClientCert
} }
tlsConfig, err := tlsconfig.Server(tlsOptions) tlsConfig, err := tlsconfig.Server(tlsOptions)
if err != nil { if err != nil {
return nil, err return nil, errors.Wrap(err, "invalid TLS configuration")
} }
serverConfig.TLSConfig = tlsConfig serverConfig.TLSConfig = tlsConfig
} }