Merge pull request #1891 from crosbymichael/new-panic

Remove panic from newCommand
This commit is contained in:
Phil Estes 2017-12-06 16:53:02 -05:00 committed by GitHub
commit ad6e751ede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,10 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
} }
defer f.Close() defer f.Close()
cmd := newCommand(binary, daemonAddress, debug, config, f) cmd, err := newCommand(binary, daemonAddress, debug, config, f)
if err != nil {
return nil, nil, err
}
ec, err := reaper.Default.Start(cmd) ec, err := reaper.Default.Start(cmd)
if err != nil { if err != nil {
return nil, nil, errors.Wrapf(err, "failed to start shim") return nil, nil, errors.Wrapf(err, "failed to start shim")
@ -87,10 +90,10 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
} }
} }
func newCommand(binary, daemonAddress string, debug bool, config shim.Config, socket *os.File) *exec.Cmd { func newCommand(binary, daemonAddress string, debug bool, config shim.Config, socket *os.File) (*exec.Cmd, error) {
selfExe, err := os.Executable() selfExe, err := os.Executable()
if err != nil { if err != nil {
panic(err) return nil, err
} }
args := []string{ args := []string{
"-namespace", config.Namespace, "-namespace", config.Namespace,
@ -123,7 +126,7 @@ func newCommand(binary, daemonAddress string, debug bool, config shim.Config, so
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
} }
return cmd return cmd, nil
} }
func newSocket(address string) (*net.UnixListener, error) { func newSocket(address string) (*net.UnixListener, error) {