Convert ExitStatus
to use fn to get details
Instead of requiring callers to read the struct fields to check for an error, provide the exit results via a function instead which is more natural. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@@ -218,8 +218,9 @@ func (w *worker) runContainer(ctx context.Context, id string) error {
|
||||
return err
|
||||
}
|
||||
status := <-statusC
|
||||
if status.Err != nil {
|
||||
if status.Err == context.DeadlineExceeded || status.Err == context.Canceled {
|
||||
_, _, err = status.Result()
|
||||
if err != nil {
|
||||
if err == context.DeadlineExceeded || err == context.Canceled {
|
||||
return nil
|
||||
}
|
||||
w.failures++
|
||||
|
@@ -60,11 +60,12 @@ var taskAttachCommand = cli.Command{
|
||||
}
|
||||
|
||||
ec := <-statusC
|
||||
if ec.Err != nil {
|
||||
code, _, err := ec.Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ec.Code != 0 {
|
||||
return cli.NewExitError("", int(ec.Code))
|
||||
if code != 0 {
|
||||
return cli.NewExitError("", int(code))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@@ -95,11 +95,12 @@ var taskExecCommand = cli.Command{
|
||||
defer stopCatch(sigc)
|
||||
}
|
||||
status := <-statusC
|
||||
if status.Err != nil {
|
||||
return status.Err
|
||||
code, _, err := status.Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if status.Code != 0 {
|
||||
return cli.NewExitError("", int(status.Code))
|
||||
if code != 0 {
|
||||
return cli.NewExitError("", int(code))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@@ -155,15 +155,16 @@ var runCommand = cli.Command{
|
||||
}
|
||||
|
||||
status := <-statusC
|
||||
if status.Err != nil {
|
||||
return status.Err
|
||||
code, _, err := status.Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := task.Delete(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if status.Code != 0 {
|
||||
return cli.NewExitError("", int(status.Code))
|
||||
if code != 0 {
|
||||
return cli.NewExitError("", int(code))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@@ -73,14 +73,15 @@ var taskStartCommand = cli.Command{
|
||||
}
|
||||
|
||||
status := <-statusC
|
||||
if status.Err != nil {
|
||||
code, _, err := status.Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := task.Delete(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if status.Code != 0 {
|
||||
return cli.NewExitError("", int(status.Code))
|
||||
if code != 0 {
|
||||
return cli.NewExitError("", int(code))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
Reference in New Issue
Block a user