Skip to content

Commit 1e88db8

Browse files
authored
fix send correct repo name in setstatus reporting (#1870)
* set correct repo in set-status endpoint
1 parent de0a222 commit 1e88db8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cli/pkg/digger/digger.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
131131
}
132132

133133
currentJob := jobs[0]
134-
repoNameForBackendReporting := strings.ReplaceAll(currentJob.Namespace, "/", "-")
135134
projectNameForBackendReporting := currentJob.ProjectName
136135
// TODO: handle the apply result summary as well to report it to backend. Possibly reporting changed resources as well
137136
// Some kind of generic terraform operation summary might need to be introduced
@@ -143,7 +142,7 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
143142
prNumber := *currentJob.PullRequestNumber
144143

145144
iacUtils := iac_utils.GetIacUtilsIacType(currentJob.IacType())
146-
batchResult, err := backendApi.ReportProjectJobStatus(repoNameForBackendReporting, projectNameForBackendReporting, jobId, "succeeded", time.Now(), &summary, "", jobPrCommentUrl, terraformOutput, iacUtils)
145+
batchResult, err := backendApi.ReportProjectJobStatus(currentJob.Namespace, projectNameForBackendReporting, jobId, "succeeded", time.Now(), &summary, "", jobPrCommentUrl, terraformOutput, iacUtils)
147146
if err != nil {
148147
log.Printf("error reporting Job status: %v.\n", err)
149148
return false, false, fmt.Errorf("error while running command: %v", err)

cli/pkg/spec/spec.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ func RunSpec(
137137

138138
jobs := []scheduler.Job{job}
139139

140-
fullRepoName := fmt.Sprintf("%v-%v", spec.VCS.RepoOwner, spec.VCS.RepoName)
141-
_, err = backendApi.ReportProjectJobStatus(fullRepoName, spec.Job.ProjectName, spec.JobId, "started", time.Now(), nil, "", "", "", nil)
140+
_, err = backendApi.ReportProjectJobStatus(spec.VCS.RepoName, spec.Job.ProjectName, spec.JobId, "started", time.Now(), nil, "", "", "", nil)
142141
if err != nil {
143142
message := fmt.Sprintf("Failed to report jobSpec status to backend. Exiting. %v", err)
144143
reportError(spec, backendApi, message, err)

libs/backendapi/diggerapi.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"path"
1717
"path/filepath"
18+
"strings"
1819
"time"
1920
)
2021

@@ -129,7 +130,8 @@ func (d DiggerApi) ReportProjectRun(namespace string, projectName string, starte
129130
return nil
130131
}
131132

132-
func (d DiggerApi) ReportProjectJobStatus(repo string, projectName string, jobId string, status string, timestamp time.Time, summary *iac_utils.IacSummary, planJson string, PrCommentUrl string, terraformOutput string, iacUtils iac_utils.IacUtils) (*scheduler.SerializedBatch, error) {
133+
func (d DiggerApi) ReportProjectJobStatus(repoFullName string, projectName string, jobId string, status string, timestamp time.Time, summary *iac_utils.IacSummary, planJson string, PrCommentUrl string, terraformOutput string, iacUtils iac_utils.IacUtils) (*scheduler.SerializedBatch, error) {
134+
repoNameForBackendReporting := strings.ReplaceAll(repoFullName, "/", "-")
133135
u, err := url.Parse(d.DiggerHost)
134136
if err != nil {
135137
log.Fatalf("Not able to parse digger cloud url: %v", err)
@@ -152,7 +154,7 @@ func (d DiggerApi) ReportProjectJobStatus(repo string, projectName string, jobId
152154
}
153155
}
154156

155-
u.Path = filepath.Join(u.Path, "repos", repo, "projects", projectName, "jobs", jobId, "set-status")
157+
u.Path = filepath.Join(u.Path, "repos", repoNameForBackendReporting, "projects", projectName, "jobs", jobId, "set-status")
156158
request := map[string]interface{}{
157159
"status": status,
158160
"timestamp": timestamp,

0 commit comments

Comments
 (0)