cmd/dockerd: loadDaemonCliConfig(): minor cleanup

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-04-22 21:53:07 +02:00
parent d9d0683862
commit 7b3463f2c5
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -390,21 +390,26 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
conf.Hosts = opts.Hosts
conf.LogLevel = opts.LogLevel
if opts.flags.Changed(FlagTLS) {
if flags.Changed("graph") && flags.Changed("data-root") {
return nil, errors.New(`cannot specify both "--graph" and "--data-root" option`)
}
if flags.Changed(FlagTLS) {
conf.TLS = &opts.TLS
}
if opts.flags.Changed(FlagTLSVerify) {
if flags.Changed(FlagTLSVerify) {
conf.TLSVerify = &opts.TLSVerify
v := true
conf.TLS = &v
}
conf.CommonTLSOptions = config.CommonTLSOptions{}
if opts.TLSOptions != nil {
conf.CommonTLSOptions.CAFile = opts.TLSOptions.CAFile
conf.CommonTLSOptions.CertFile = opts.TLSOptions.CertFile
conf.CommonTLSOptions.KeyFile = opts.TLSOptions.KeyFile
conf.CommonTLSOptions = config.CommonTLSOptions{
CAFile: opts.TLSOptions.CAFile,
CertFile: opts.TLSOptions.CertFile,
KeyFile: opts.TLSOptions.KeyFile,
}
} else {
conf.CommonTLSOptions = config.CommonTLSOptions{}
}
if conf.TrustKeyPath == "" {
@ -415,10 +420,6 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
conf.TrustKeyPath = filepath.Join(daemonConfDir, defaultTrustKeyFile)
}
if flags.Changed("graph") && flags.Changed("data-root") {
return nil, errors.New(`cannot specify both "--graph" and "--data-root" option`)
}
if opts.configFile != "" {
c, err := config.MergeDaemonConfigurations(conf, flags, opts.configFile)
if err != nil {