mirror of
https://github.com/moby/moby.git
synced 2026-08-04 23:21:00 +00:00
cmd/dockerd: remove unused error-returns
getDefaultDaemonConfigDir would never return an error and because of that, neither would getDefaultDaemonConfigFile, so we can remove these error returns. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -19,8 +19,7 @@ func defaultOptions(t *testing.T, configFile string) *daemonOptions {
|
||||
opts.flags = &pflag.FlagSet{}
|
||||
opts.installFlags(opts.flags)
|
||||
installConfigFlags(opts.daemonConfig, opts.flags)
|
||||
defaultDaemonConfigFile, err := getDefaultDaemonConfigFile()
|
||||
assert.NilError(t, err)
|
||||
defaultDaemonConfigFile := getDefaultDaemonConfigFile()
|
||||
opts.flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "")
|
||||
opts.configFile = configFile
|
||||
err = opts.flags.Parse([]string{})
|
||||
|
||||
@@ -21,26 +21,26 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func getDefaultDaemonConfigDir() (string, error) {
|
||||
func getDefaultDaemonConfigDir() string {
|
||||
if !honorXDG {
|
||||
return "/etc/docker", nil
|
||||
return "/etc/docker"
|
||||
}
|
||||
// NOTE: CLI uses ~/.docker while the daemon uses ~/.config/docker, because
|
||||
// ~/.docker was not designed to store daemon configurations.
|
||||
// In future, the daemon directory may be renamed to ~/.config/moby-engine (?).
|
||||
configHome, err := homedir.GetConfigHome()
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(configHome, "docker"), nil
|
||||
return filepath.Join(configHome, "docker")
|
||||
}
|
||||
|
||||
func getDefaultDaemonConfigFile() (string, error) {
|
||||
dir, err := getDefaultDaemonConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
func getDefaultDaemonConfigFile() string {
|
||||
dir := getDefaultDaemonConfigDir()
|
||||
if dir == "" {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(dir, "daemon.json"), nil
|
||||
return filepath.Join(dir, "daemon.json")
|
||||
}
|
||||
|
||||
// setDefaultUmask sets the umask to 0022 to avoid problems
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func getDefaultDaemonConfigFile() (string, error) {
|
||||
return "", nil
|
||||
func getDefaultDaemonConfigFile() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// loadCLIPlatformConfig loads the platform specific CLI configuration
|
||||
|
||||
@@ -43,11 +43,7 @@ func newDaemonCommand() (*cobra.Command, error) {
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.BoolP("version", "v", false, "Print version information and quit")
|
||||
defaultDaemonConfigFile, err := getDefaultDaemonConfigFile()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "Daemon configuration file")
|
||||
flags.StringVar(&opts.configFile, "config-file", getDefaultDaemonConfigFile(), "Daemon configuration file")
|
||||
configureCertsDir()
|
||||
opts.installFlags(flags)
|
||||
installConfigFlags(opts.daemonConfig, flags)
|
||||
|
||||
Reference in New Issue
Block a user