Apply reads requests from the provided directory to stream responses.
(sess *provisionersdk.Session, req *proto.ApplyRequest, canceledOrComplete <-chan struct{})
| 283 | |
| 284 | // Apply reads requests from the provided directory to stream responses. |
| 285 | func (*echo) Apply(sess *provisionersdk.Session, req *proto.ApplyRequest, canceledOrComplete <-chan struct{}) *proto.ApplyComplete { |
| 286 | responses, err := readResponses( |
| 287 | sess, |
| 288 | strings.ToLower(req.GetMetadata().GetWorkspaceTransition().String()), |
| 289 | "apply.protobuf") |
| 290 | if err != nil { |
| 291 | return &proto.ApplyComplete{Error: err.Error()} |
| 292 | } |
| 293 | for _, response := range responses { |
| 294 | if log := response.GetLog(); log != nil { |
| 295 | sess.ProvisionLog(log.Level, log.Output) |
| 296 | } |
| 297 | if complete := response.GetApply(); complete != nil { |
| 298 | return complete |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | // some tests use Echo without a complete response to test cancel |
| 303 | <-canceledOrComplete |
| 304 | return provisionersdk.ApplyErrorf("canceled") |
| 305 | } |
| 306 | |
| 307 | func (*echo) Shutdown(_ context.Context, _ *proto.Empty) (*proto.Empty, error) { |
| 308 | return &proto.Empty{}, nil |
nothing calls this directly
no test coverage detected