Skip to content

fix send correct repo name in setstatus reporting #1870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cli/pkg/digger/digger.go
Original file line number Diff line number Diff line change
@@ -131,7 +131,6 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
}

currentJob := jobs[0]
repoNameForBackendReporting := strings.ReplaceAll(currentJob.Namespace, "/", "-")
projectNameForBackendReporting := currentJob.ProjectName
// TODO: handle the apply result summary as well to report it to backend. Possibly reporting changed resources as well
// 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
prNumber := *currentJob.PullRequestNumber

iacUtils := iac_utils.GetIacUtilsIacType(currentJob.IacType())
batchResult, err := backendApi.ReportProjectJobStatus(repoNameForBackendReporting, projectNameForBackendReporting, jobId, "succeeded", time.Now(), &summary, "", jobPrCommentUrl, terraformOutput, iacUtils)
batchResult, err := backendApi.ReportProjectJobStatus(currentJob.Namespace, projectNameForBackendReporting, jobId, "succeeded", time.Now(), &summary, "", jobPrCommentUrl, terraformOutput, iacUtils)
if err != nil {
log.Printf("error reporting Job status: %v.\n", err)
return false, false, fmt.Errorf("error while running command: %v", err)
3 changes: 1 addition & 2 deletions cli/pkg/spec/spec.go
Original file line number Diff line number Diff line change
@@ -137,8 +137,7 @@ func RunSpec(

jobs := []scheduler.Job{job}

fullRepoName := fmt.Sprintf("%v-%v", spec.VCS.RepoOwner, spec.VCS.RepoName)
_, err = backendApi.ReportProjectJobStatus(fullRepoName, spec.Job.ProjectName, spec.JobId, "started", time.Now(), nil, "", "", "", nil)
_, err = backendApi.ReportProjectJobStatus(spec.VCS.RepoName, spec.Job.ProjectName, spec.JobId, "started", time.Now(), nil, "", "", "", nil)
if err != nil {
message := fmt.Sprintf("Failed to report jobSpec status to backend. Exiting. %v", err)
reportError(spec, backendApi, message, err)
6 changes: 4 additions & 2 deletions libs/backendapi/diggerapi.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"time"
)

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

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) {
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) {
repoNameForBackendReporting := strings.ReplaceAll(repoFullName, "/", "-")
u, err := url.Parse(d.DiggerHost)
if err != nil {
log.Fatalf("Not able to parse digger cloud url: %v", err)
@@ -152,7 +154,7 @@ func (d DiggerApi) ReportProjectJobStatus(repo string, projectName string, jobId
}
}

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