Fixed panic when job has trigger and in development mode (#1026)

## Changes
Fixed panic when job has trigger and in development mode
This commit is contained in:
Andrew Nester 2023-11-29 17:32:42 +01:00 committed by GitHub
parent f2969e91bd
commit 4d8d825746
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -54,10 +54,10 @@ func transformDevelopmentMode(b *bundle.Bundle) error {
if r.Jobs[i].Schedule != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Schedule.PauseStatus = jobs.PauseStatusPaused
}
if r.Jobs[i].Continuous != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
if r.Jobs[i].Continuous != nil && r.Jobs[i].Continuous.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Continuous.PauseStatus = jobs.PauseStatusPaused
}
if r.Jobs[i].Trigger != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
if r.Jobs[i].Trigger != nil && r.Jobs[i].Trigger.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Trigger.PauseStatus = jobs.PauseStatusPaused
}
}

View File

@ -62,6 +62,24 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
},
},
},
"job3": {
JobSettings: &jobs.JobSettings{
Name: "job3",
Trigger: &jobs.TriggerSettings{
FileArrival: &jobs.FileArrivalTriggerConfiguration{
Url: "test.com",
},
},
},
},
"job4": {
JobSettings: &jobs.JobSettings{
Name: "job4",
Continuous: &jobs.Continuous{
PauseStatus: jobs.PauseStatusPaused,
},
},
},
},
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1"}},
@ -205,6 +223,8 @@ func TestProcessTargetModeProduction(t *testing.T) {
b.Config.Resources.Jobs["job1"].Permissions = permissions
b.Config.Resources.Jobs["job1"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
b.Config.Resources.Jobs["job2"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
b.Config.Resources.Jobs["job3"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
b.Config.Resources.Jobs["job4"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
b.Config.Resources.Pipelines["pipeline1"].Permissions = permissions
b.Config.Resources.Experiments["experiment1"].Permissions = permissions
b.Config.Resources.Experiments["experiment2"].Permissions = permissions