Skip to content

Commit

Permalink
fix: update execution output the old way, if the Control Plane doesn'…
Browse files Browse the repository at this point in the history
…t support a new one (#6192)
  • Loading branch information
rangoo94 authored Feb 21, 2025
1 parent bcb3d72 commit c4cff26
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/controlplaneclient/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func (c *client) SaveExecutionLogs(ctx context.Context, environmentId, execution

// TODO: Create AppendExecutionOutput (and maybe ResetExecutionOutput?) instead
func (c *client) UpdateExecutionOutput(ctx context.Context, environmentId, executionId string, output []testkube.TestWorkflowOutput) error {
if c.IsLegacy() {
return c.legacyUpdateExecutionOutput(ctx, environmentId, executionId, output)
}
req := &cloud.UpdateExecutionOutputRequest{
Id: executionId,
Output: common.MapSlice(output, func(t testkube.TestWorkflowOutput) *cloud.ExecutionOutput {
Expand Down Expand Up @@ -255,3 +258,24 @@ func (c *client) legacyInitExecution(ctx context.Context, environmentId, executi
_, err = call(ctx, c.metadata().SetEnvironmentID(environmentId).GRPC(), c.client.Call, &req)
return err
}

// Deprecated
func (c *client) legacyUpdateExecutionOutput(ctx context.Context, environmentId, executionId string, output []testkube.TestWorkflowOutput) error {
jsonPayload, err := json.Marshal(cloudtestworkflow.ExecutionUpdateOutputRequest{
ID: executionId,
Output: output,
})
if err != nil {
return err
}
s := structpb.Struct{}
if err := s.UnmarshalJSON(jsonPayload); err != nil {
return err
}
req := cloud.CommandRequest{
Command: string(cloudtestworkflow.CmdTestWorkflowExecutionUpdateOutput),
Payload: &s,
}
_, err = call(ctx, c.metadata().SetEnvironmentID(environmentId).GRPC(), c.client.Call, &req)
return err
}

0 comments on commit c4cff26

Please sign in to comment.