Skip to content

Commit cf5fa92

Browse files
committed
fix build
1 parent 93da167 commit cf5fa92

File tree

8 files changed

+23
-28
lines changed

8 files changed

+23
-28
lines changed

backend/controllers/github.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,10 @@ func TriggerDiggerJobs(client *github.Client, repoOwner string, repoName string,
675675
log.Printf("number of diggerJobs:%v\n", len(diggerJobs))
676676

677677
for _, job := range diggerJobs {
678-
if job.SerializedJob == nil {
678+
if job.SerializedJobSpec == nil {
679679
return fmt.Errorf("GitHub job can't be nil")
680680
}
681-
jobString := string(job.SerializedJob)
681+
jobString := string(job.SerializedJobSpec)
682682
log.Printf("jobString: %v \n", jobString)
683683

684684
// TODO: make workflow file name configurable

backend/controllers/projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func SetJobStatusForProject(c *gin.Context) {
342342

343343
// store digger job summary
344344
if request.JobSummary != nil {
345-
models.DB.UpdateDiggerJobSummary(job.DiggerJobId, request.JobSummary.ResourcesCreated, request.JobSummary.ResourcesUpdated, request.JobSummary.ResourcesDeleted)
345+
models.DB.UpdateDiggerJobSummary(job.DiggerJobID, request.JobSummary.ResourcesCreated, request.JobSummary.ResourcesUpdated, request.JobSummary.ResourcesDeleted)
346346
}
347347

348348
case "failed":

backend/models/scheduler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type DiggerJob struct {
3939
BatchID *string `gorm:"index:idx_digger_job_id"`
4040
DiggerJobSummary DiggerJobSummary
4141
DiggerJobSummaryID uint
42-
SerializedJob []byte
42+
SerializedJobSpec []byte
4343
StatusUpdatedAt time.Time
4444
}
4545

@@ -69,14 +69,14 @@ type GithubDiggerJobLink struct {
6969

7070
func (j *DiggerJob) MapToJsonStruct() interface{} {
7171
var job orchestrator.JobJson
72-
err := json.Unmarshal(j.SerializedJob, &job)
72+
err := json.Unmarshal(j.SerializedJobSpec, &job)
7373
if err != nil {
7474
log.Printf("Failed to convert unmarshall Serialized job")
7575
}
7676
return orchestrator_scheduler.SerializedJob{
7777
DiggerJobId: j.DiggerJobID,
7878
Status: j.Status,
79-
JobString: j.SerializedJob,
79+
JobString: j.SerializedJobSpec,
8080
ProjectName: job.ProjectName,
8181
ResourcesCreated: j.DiggerJobSummary.ResourcesCreated,
8282
ResourcesUpdated: j.DiggerJobSummary.ResourcesUpdated,

backend/models/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ func (db *Database) CreateDiggerJob(batchId uuid.UUID, serializedJob []byte) (*D
634634
}
635635

636636
job := &DiggerJob{DiggerJobID: jobId, Status: scheduler.DiggerJobCreated,
637-
BatchID: &batchIdStr, SerializedJob: serializedJob, DiggerJobSummary: *summary}
637+
BatchID: &batchIdStr, SerializedJobSpec: serializedJob, DiggerJobSummary: *summary}
638638
result = db.GormDB.Save(job)
639639
if result.Error != nil {
640640
return nil, result.Error

backend/models/storage_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package models
22

33
import (
4+
"github.com/davecgh/go-spew/spew"
45
"github.com/diggerhq/digger/libs/orchestrator/scheduler"
56
"github.com/stretchr/testify/assert"
67
"gorm.io/driver/sqlite"
@@ -152,22 +153,16 @@ func TestGetDiggerJobsForBatchPreloadsSummary(t *testing.T) {
152153
job, err := DB.CreateDiggerJob(batch.ID, []byte{97})
153154
assert.NoError(t, err)
154155

155-
job, err = DB.UpdateDiggerJobSummary(job.DiggerJobId, 1, 2, 3)
156+
job, err = DB.UpdateDiggerJobSummary(job.DiggerJobID, 1, 2, 3)
156157
assert.NoError(t, err)
157158

158-
//fetchedBatch, err := DB.GetDiggerBatch(&batch.ID)
159-
//assert.NoError(t, err)
160-
//jsons, err := fetchedBatch.MapToJsonStruct()
161-
//assert.NoError(t, err)
162-
163-
//jobs := job.MapToJsonStruct()
164-
//
165-
//println(job.DiggerJobSummary.ResourcesCreated, job.DiggerJobSummary.ResourcesUpdated, job.DiggerJobSummary.ResourcesDeleted)
166-
//spew.Dump(jsons)
167-
//spew.Dump(jobs)
168-
169159
jobssss, err := DB.GetDiggerJobsForBatch(batch.ID)
170160
println(job.DiggerJobSummary.ResourcesCreated, job.DiggerJobSummary.ResourcesUpdated, job.DiggerJobSummary.ResourcesDeleted)
171161
println(jobssss[0].DiggerJobSummary.ResourcesCreated, jobssss[0].DiggerJobSummary.ResourcesUpdated, jobssss[0].DiggerJobSummary.ResourcesDeleted)
172162

163+
fetchedBatch, err := DB.GetDiggerBatch(&batch.ID)
164+
assert.NoError(t, err)
165+
jsons, err := fetchedBatch.MapToJsonStruct()
166+
assert.NoError(t, err)
167+
spew.Dump(jsons)
173168
}

backend/services/scheduler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
)
1111

1212
func DiggerJobCompleted(client *github.Client, batchId *uuid.UUID, parentJob *models.DiggerJob, repoOwner string, repoName string, workflowFileName string) error {
13-
log.Printf("DiggerJobCompleted parentJobId: %v", parentJob.DiggerJobId)
13+
log.Printf("DiggerJobCompleted parentJobId: %v", parentJob.DiggerJobID)
1414

15-
jobLinksForParent, err := models.DB.GetDiggerJobParentLinksByParentId(&parentJob.DiggerJobId)
15+
jobLinksForParent, err := models.DB.GetDiggerJobParentLinksByParentId(&parentJob.DiggerJobID)
1616
if err != nil {
1717
return err
1818
}
@@ -50,18 +50,18 @@ func DiggerJobCompleted(client *github.Client, batchId *uuid.UUID, parentJob *mo
5050
}
5151

5252
func TriggerJob(client *github.Client, repoOwner string, repoName string, batchId *uuid.UUID, job *models.DiggerJob, workflowFileName string) {
53-
log.Printf("TriggerJob jobId: %v", job.DiggerJobId)
53+
log.Printf("TriggerJob jobId: %v", job.DiggerJobID)
5454

5555
batch, err := models.DB.GetDiggerBatch(batchId)
5656
if err != nil {
5757
log.Printf("TriggerJob err: %v\n", err)
5858
return
5959
}
6060

61-
if job.SerializedJob == nil {
61+
if job.SerializedJobSpec == nil {
6262
log.Printf("GitHub job can't be nil")
6363
}
64-
jobString := string(job.SerializedJob)
64+
jobString := string(job.SerializedJobSpec)
6565
log.Printf("jobString: %v \n", jobString)
6666

6767
err = utils.TriggerGithubWorkflow(client, repoOwner, repoName, *job, jobString, *batch.CommentId)

backend/utils/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TriggerGithubWorkflow(client *github.Client, repoOwner string, repoName str
141141
log.Printf("TriggerGithubWorkflow: repoOwner: %v, repoName: %v, commentId: %v", repoOwner, repoName, commentId)
142142
_, err := client.Actions.CreateWorkflowDispatchEventByFileName(context.Background(), repoOwner, repoName, "digger_workflow.yml", github.CreateWorkflowDispatchEventRequest{
143143
Ref: job.Batch.BranchName,
144-
Inputs: map[string]interface{}{"job": jobString, "id": job.DiggerJobId, "comment_id": strconv.FormatInt(commentId, 10)},
144+
Inputs: map[string]interface{}{"job": jobString, "id": job.DiggerJobID, "comment_id": strconv.FormatInt(commentId, 10)},
145145
})
146146
return err
147147
}

backend/utils/graphs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func ConvertJobsToDiggerJobs(jobsMap map[string]orchestrator.Job, projectMap map
5252
log.Printf("failed to create a job, error: %v", err)
5353
return false
5454
}
55-
_, err = models.DB.CreateDiggerJobLink(parentJob.DiggerJobId, repoFullName)
55+
_, err = models.DB.CreateDiggerJobLink(parentJob.DiggerJobID, repoFullName)
5656
if err != nil {
5757
log.Printf("failed to create a digger job link")
5858
return false
@@ -70,12 +70,12 @@ func ConvertJobsToDiggerJobs(jobsMap map[string]orchestrator.Job, projectMap map
7070
log.Printf("failed to create a job")
7171
return false
7272
}
73-
_, err = models.DB.CreateDiggerJobLink(childJob.DiggerJobId, repoFullName)
73+
_, err = models.DB.CreateDiggerJobLink(childJob.DiggerJobID, repoFullName)
7474
if err != nil {
7575
log.Printf("failed to create a digger job link")
7676
return false
7777
}
78-
err = models.DB.CreateDiggerJobParentLink(parentDiggerJob.DiggerJobId, childJob.DiggerJobId)
78+
err = models.DB.CreateDiggerJobParentLink(parentDiggerJob.DiggerJobID, childJob.DiggerJobID)
7979
if err != nil {
8080
log.Printf("failed to create a digger job parent link")
8181
return false

0 commit comments

Comments
 (0)