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:
Sebastiaan van Stijn
2024-02-21 14:20:28 +01:00
parent 1624ae197e
commit 388c0a8cda
4 changed files with 13 additions and 18 deletions

View File

@@ -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{})

View File

@@ -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

View File

@@ -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

View File

@@ -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)