(ctx context.Context, d *internal.Display, req *proto.ExecRequest)
| 257 | } |
| 258 | |
| 259 | func runExecServer(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) { |
| 260 | conn, err := connect(execServerAddr) |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | defer conn.Close() |
| 265 | |
| 266 | client := proto.NewControllerServiceClient(conn) |
| 267 | stream, err := client.Exec(ctx, req) |
| 268 | if err != nil { |
| 269 | return nil, fmt.Errorf("error executing: %w", err) |
| 270 | } |
| 271 | |
| 272 | var confirmation *proto.ConfirmationContent |
| 273 | var lastSeq int32 |
| 274 | for { |
| 275 | resp, err := stream.Recv() |
| 276 | if err == io.EOF { |
| 277 | break |
| 278 | } |
| 279 | if err != nil { |
| 280 | return nil, fmt.Errorf("error receiving response: %w", err) |
| 281 | } |
| 282 | lastSeq = resp.Seq |
| 283 | if resp.Outputs != nil { |
| 284 | for _, m := range resp.Outputs { |
| 285 | if conf := m.GetContent().GetConfirmation(); conf != nil { |
| 286 | confirmation = conf |
| 287 | } |
| 288 | } |
| 289 | displayContents(d, resp.Outputs) |
| 290 | } |
| 291 | } |
| 292 | if confirmation == nil { |
| 293 | d.FinishOutput(fmt.Sprintf("seq=%d", lastSeq)) |
| 294 | } |
| 295 | return confirmation, nil |
| 296 | } |
| 297 | |
| 298 | func displayContents(d *internal.Display, contents []*proto.Message) { |
| 299 | for _, output := range contents { |
nothing calls this directly
no test coverage detected