(ctx context.Context, filters ...string)
| 80 | var errStreamNotAvailable = errors.New("streaming api not available") |
| 81 | |
| 82 | func (r *remoteContainers) stream(ctx context.Context, filters ...string) ([]containers.Container, error) { |
| 83 | session, err := r.client.ListStream(ctx, &containersapi.ListContainersRequest{ |
| 84 | Filters: filters, |
| 85 | }) |
| 86 | if err != nil { |
| 87 | return nil, errgrpc.ToNative(err) |
| 88 | } |
| 89 | var containers []containers.Container |
| 90 | for { |
| 91 | c, err := session.Recv() |
| 92 | if err != nil { |
| 93 | if err == io.EOF { |
| 94 | return containers, nil |
| 95 | } |
| 96 | if s, ok := status.FromError(err); ok { |
| 97 | if s.Code() == codes.Unimplemented { |
| 98 | return nil, errStreamNotAvailable |
| 99 | } |
| 100 | } |
| 101 | return nil, errgrpc.ToNative(err) |
| 102 | } |
| 103 | select { |
| 104 | case <-ctx.Done(): |
| 105 | return containers, ctx.Err() |
| 106 | default: |
| 107 | containers = append(containers, containerFromProto(c.Container)) |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func (r *remoteContainers) Create(ctx context.Context, container containers.Container) (containers.Container, error) { |
| 113 | created, err := r.client.Create(ctx, &containersapi.CreateContainerRequest{ |
no test coverage detected