Fetch current container info before operations
This makes sure the client is always in sync with the server before performing any type of operations on the container metadata. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ var taskAttachCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
spec, err := container.Spec()
|
||||
spec, err := container.Spec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -49,15 +49,18 @@ var containersCommand = cli.Command{
|
||||
w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0)
|
||||
fmt.Fprintln(w, "CONTAINER\tIMAGE\tRUNTIME\t")
|
||||
for _, c := range containers {
|
||||
imageName := c.Info().Image
|
||||
info, err := c.Info(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imageName := info.Image
|
||||
if imageName == "" {
|
||||
imageName = "-"
|
||||
}
|
||||
record := c.Info()
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t\n",
|
||||
c.ID(),
|
||||
imageName,
|
||||
record.Runtime.Name,
|
||||
info.Runtime.Name,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ var taskExecCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
spec, err := container.Spec()
|
||||
spec, err := container.Spec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -28,7 +28,11 @@ var containerInfoCommand = cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
printAsJSON(container.Info())
|
||||
info, err := container.Info(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printAsJSON(info)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ var taskStartCommand = cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
spec, err := container.Spec()
|
||||
spec, err := container.Spec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user