Skip to content

Commit

Permalink
Merge pull request moby#48519 from thaJeztah/cleanup_daemon_start_step2
Browse files Browse the repository at this point in the history
cmd/dockerd: runDaemon: extract platform-agnostic code
  • Loading branch information
thaJeztah authored Sep 17, 2024
2 parents 408f51b + 8c598b1 commit 92da106
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
13 changes: 12 additions & 1 deletion cmd/dockerd/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ func newDaemonCommand() (*cobra.Command, error) {
Args: NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
opts.flags = cmd.Flags()
return runDaemon(cmd.Context(), opts)

cli, err := newDaemonCLI(opts)
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")
return nil
}

return runDaemon(cmd.Context(), cli)
},
DisableFlagsInUseLine: true,
Version: fmt.Sprintf("%s, build %s", dockerversion.Version, dockerversion.GitCommit),
Expand Down
13 changes: 1 addition & 12 deletions cmd/dockerd/docker_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,12 @@ package main

import (
"context"
"fmt"
"io"
"os"

"github.com/containerd/log"
)

func runDaemon(ctx context.Context, opts *daemonOptions) error {
cli, err := newDaemonCLI(opts)
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")
return nil
}
func runDaemon(ctx context.Context, cli *daemonCLI) error {
return cli.start(ctx)
}

Expand Down
14 changes: 1 addition & 13 deletions cmd/dockerd/docker_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,13 @@ package main

import (
"context"
"fmt"
"io"
"os"

"github.com/Microsoft/go-winio/pkg/etwlogrus"
"github.com/containerd/log"
)

func runDaemon(ctx context.Context, opts *daemonOptions) error {
cli, err := newDaemonCLI(opts)
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")
return nil
}

func runDaemon(ctx context.Context, cli *daemonCLI) error {
// On Windows, this may be launching as a service or with an option to
// register the service.
stop, runAsService, err := initService(cli)
Expand Down

0 comments on commit 92da106

Please sign in to comment.