@@ -19,6 +19,16 @@ var SendToSplunkCmd = &cobra.Command{
1919 splunkToken , _ := cmd .Flags ().GetString ("splunk-token" )
2020 splunkEvent , _ := cmd .Flags ().GetString ("splunk-event" )
2121 failLogsURL , _ := cmd .Flags ().GetString ("failed-logs-url" )
22+ repoURL , _ := cmd .Flags ().GetString ("repo-url" )
23+ branchName , _ := cmd .Flags ().GetString ("branch-name" )
24+ headSHA , _ := cmd .Flags ().GetString ("head-sha" )
25+ baseSHA , _ := cmd .Flags ().GetString ("base-sha" )
26+ githubWorkflowName , _ := cmd .Flags ().GetString ("github-workflow-name" )
27+ githubWorkflowRunURL , _ := cmd .Flags ().GetString ("github-workflow-run-url" )
28+ reportID , _ := cmd .Flags ().GetString ("report-id" )
29+ genReportID , _ := cmd .Flags ().GetBool ("gen-report-id" )
30+ repoPath , _ := cmd .Flags ().GetString ("repo-path" )
31+ codeownersPath , _ := cmd .Flags ().GetString ("codeowners-path" )
2232
2333 // Read the report file.
2434 data , err := os .ReadFile (reportPath )
@@ -33,12 +43,49 @@ var SendToSplunkCmd = &cobra.Command{
3343 log .Error ().Err (err ).Msg ("Error unmarshalling report JSON" )
3444 os .Exit (1 )
3545 }
46+ testReport .GenerateSummaryData ()
3647
48+ // Override report fields with flags if provided.
49+ if repoURL != "" {
50+ testReport .RepoURL = repoURL
51+ }
52+ if branchName != "" {
53+ testReport .BranchName = branchName
54+ }
55+ if headSHA != "" {
56+ testReport .HeadSHA = headSHA
57+ }
58+ if baseSHA != "" {
59+ testReport .BaseSHA = baseSHA
60+ }
61+ if githubWorkflowName != "" {
62+ testReport .GitHubWorkflowName = githubWorkflowName
63+ }
64+ if githubWorkflowRunURL != "" {
65+ testReport .GitHubWorkflowRunURL = githubWorkflowRunURL
66+ }
67+ if reportID != "" {
68+ testReport .SetReportID (reportID )
69+ }
70+ if genReportID {
71+ testReport .SetRandomReportID ()
72+ }
73+ if repoPath != "" {
74+ err = reports .MapTestResultsToPaths (& testReport , repoPath )
75+ if err != nil {
76+ log .Error ().Err (err ).Msg ("Error mapping test results to paths" )
77+ os .Exit (1 )
78+ }
79+ }
80+ if codeownersPath != "" && repoPath != "" {
81+ reports .MapTestResultsToOwners (& testReport , codeownersPath )
82+ }
3783 if failLogsURL != "" {
3884 testReport .FailedLogsURL = failLogsURL
3985 }
4086
41- err = reports .SendReportToSplunk (splunkURL , splunkToken , splunkEvent , testReport )
87+ // Send the test report to Splunk.
88+ err = reports .SendTestReportToSplunk (splunkURL , splunkToken , splunkEvent , testReport )
4289 if err != nil {
4390 log .Error ().Err (err ).Msg ("Error sending test report to Splunk" )
4491 os .Exit (1 )
@@ -55,6 +102,16 @@ func init() {
55102 SendToSplunkCmd .Flags ().String ("splunk-url" , "" , "Optional URL to send the test results to Splunk" )
56103 SendToSplunkCmd .Flags ().String ("splunk-token" , "" , "Optional Splunk HEC token to send the test results" )
57104 SendToSplunkCmd .Flags ().String ("splunk-event" , "" , "Optional Splunk event to send as the triggering event for the test results" )
105+ SendToSplunkCmd .Flags ().String ("repo-url" , "" , "The repository URL" )
106+ SendToSplunkCmd .Flags ().String ("branch-name" , "" , "Branch name for the test report" )
107+ SendToSplunkCmd .Flags ().String ("head-sha" , "" , "Head commit SHA for the test report" )
108+ SendToSplunkCmd .Flags ().String ("base-sha" , "" , "Base commit SHA for the test report" )
109+ SendToSplunkCmd .Flags ().String ("github-workflow-name" , "" , "GitHub workflow name for the test report" )
110+ SendToSplunkCmd .Flags ().String ("github-workflow-run-url" , "" , "GitHub workflow run URL for the test report" )
111+ SendToSplunkCmd .Flags ().String ("report-id" , "" , "Optional identifier for the test report. Will be generated if not provided" )
112+ SendToSplunkCmd .Flags ().StringP ("repo-path" , "" , "." , "The path to the root of the repository/project" )
113+ SendToSplunkCmd .Flags ().StringP ("codeowners-path" , "" , "" , "Path to the CODEOWNERS file" )
114+ SendToSplunkCmd .Flags ().Bool ("gen-report-id" , false , "Generate a random report ID" )
58115
59116 // Mark required flags.
60117 if err := SendToSplunkCmd .MarkFlagRequired ("report-path" ); err != nil {
0 commit comments