cmd/dockerd: fix some minor issues in Windows implementation

- properly use filepath.Join() for Windows paths
- use getDaemonConfDir() to get the path for storing daemon.json
- return error instead of logrus.Fatal(). The logrus.Fatal() was a left-over
  from when Cobra was not used, and appears to have been missed in commit
  fb83394714, which did the conversion to Cobra.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-08-09 22:13:18 +02:00
parent ad8d255bb9
commit 37a241768d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 7 additions and 3 deletions

View File

@ -24,7 +24,7 @@ func setDefaultUmask() error {
} }
func getDaemonConfDir(root string) (string, error) { func getDaemonConfDir(root string) (string, error) {
return filepath.Join(root, `\config`), nil return filepath.Join(root, "config"), nil
} }
// preNotifyReady sends a message to the host when the API is active, but before the daemon is // preNotifyReady sends a message to the host when the API is active, but before the daemon is

View File

@ -15,7 +15,7 @@ func runDaemon(opts *daemonOptions) error {
// register the service. // register the service.
stop, runAsService, err := initService(daemonCli) stop, runAsService, err := initService(daemonCli)
if err != nil { if err != nil {
logrus.Fatal(err) return err
} }
if stop { if stop {
@ -24,7 +24,11 @@ func runDaemon(opts *daemonOptions) error {
// Windows specific settings as these are not defaulted. // Windows specific settings as these are not defaulted.
if opts.configFile == "" { if opts.configFile == "" {
opts.configFile = filepath.Join(opts.daemonConfig.Root, `config\daemon.json`) configDir, err := getDaemonConfDir(opts.daemonConfig.Root)
if err != nil {
return err
}
opts.configFile = filepath.Join(configDir, "daemon.json")
} }
if runAsService { if runAsService {
// If Windows SCM manages the service - no need for PID files // If Windows SCM manages the service - no need for PID files