Skip to content

Commit

Permalink
Merge pull request #6 from avi-biton/adjust_message
Browse files Browse the repository at this point in the history
chore(RHTAPWATCH-1159): add pipelinerun name to message sent to SNS
  • Loading branch information
avi-biton authored Jul 18, 2024
2 parents b1db220 + b4e770e commit d195f4d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/controller/pipelinerun_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,20 @@ func RemoveFinalizerFromPipelineRun(ctx context.Context, pipelineRun *tektonv1.P
}

// GetResultsFromPipelineRun extracts results from pipelinerun
// Return error if failed to extract results
// And adds the pipelinerunName
// Return error if failed to extract results or if results does not exist
func GetResultsFromPipelineRun(pipelineRun *tektonv1.PipelineRun) ([]byte, error) {
results, err := json.Marshal(pipelineRun.Status.Results)
namedResults := []tektonv1.PipelineRunResult{
{
Name: "PIPELINERUN_NAME",
Value: *tektonv1.NewStructuredValues(pipelineRun.Name),
},
}
fetchedResults := pipelineRun.Status.Results
fullResults := append(namedResults, fetchedResults...)
results, err := json.Marshal(fullResults)
if err != nil {
return nil, fmt.Errorf("failed to get results from pipelinerun %s: %w", pipelineRun.Name, err)
return nil, fmt.Errorf("failed to marshel results from pipelinerun %s: %w", pipelineRun.Name, err)
}
return results, nil
}
Expand Down

0 comments on commit d195f4d

Please sign in to comment.