Skip to content

Commit

Permalink
fix: Fix when deploying many jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mzottola committed Dec 20, 2023
1 parent 29a0264 commit c6639ba
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions utils/qovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,6 @@ func DeployJobs(client *qovery.APIClient, envId string, jobNames string, commitI
return fmt.Errorf("job %s not found", trimmedJobName)
}


var docker = GetJobDocker(job)
var image = GetJobImage(job)

Expand Down Expand Up @@ -1462,21 +1461,21 @@ func DeployJobs(client *qovery.APIClient, envId string, jobNames string, commitI
return deployAllServices(client, envId, req)
}
func GetJobDocker(job *qovery.JobResponse) *qovery.BaseJobResponseAllOfSourceOneOf1Docker {
if job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf1 != nil {
if job.CronJobResponse != nil && job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf1 != nil {
return job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf1.Docker
}

if job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf1 != nil {
if job.LifecycleJobResponse != nil && job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf1 != nil {
return job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf1.Docker
}
return nil
}

func GetJobImage(job *qovery.JobResponse) *qovery.ContainerSource {
if job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf != nil {
if job.CronJobResponse != nil && job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf != nil {
return job.CronJobResponse.Source.BaseJobResponseAllOfSourceOneOf.Image
}
if job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf != nil {
if job.LifecycleJobResponse != nil && job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf != nil {
return job.LifecycleJobResponse.Source.BaseJobResponseAllOfSourceOneOf.Image
}
return nil
Expand Down Expand Up @@ -1557,7 +1556,6 @@ func DeployHelms(client *qovery.APIClient, envId string, helmNames string, chart
return fmt.Errorf("helm %s not found", trimmedHelmName)
}


var gitSource = GetGitSource(helm)
var helmRepositorySource = GetHelmRepository(helm)

Expand Down Expand Up @@ -1585,11 +1583,10 @@ func DeployHelms(client *qovery.APIClient, envId string, helmNames string, chart
mValuesOverrideCommitId = &valuesOverrideCommitId
}


helmsToDeploy = append(helmsToDeploy, qovery.DeployAllRequestHelmsInner{
Id: &helm.Id,
ChartVersion: mChartVersion,
GitCommitId: mCommitId,
Id: &helm.Id,
ChartVersion: mChartVersion,
GitCommitId: mCommitId,
ValuesOverrideGitCommitId: mValuesOverrideCommitId,
})
}
Expand All @@ -1605,7 +1602,6 @@ func DeployHelms(client *qovery.APIClient, envId string, helmNames string, chart
return deployAllServices(client, envId, req)
}


func GetGitSource(helm *qovery.HelmResponse) *qovery.ApplicationGitRepositoryRequest {
if helm.Source.HelmResponseAllOfSourceOneOf != nil && helm.Source.HelmResponseAllOfSourceOneOf.Git != nil {
return helm.Source.HelmResponseAllOfSourceOneOf.Git.GitRepository
Expand Down Expand Up @@ -2429,8 +2425,8 @@ func ToJobRequest(job qovery.JobResponse) qovery.JobRequest {
}
} else {
var scheduleCronjob = qovery.JobRequestAllOfScheduleCronjob{
Entrypoint: job.CronJobResponse.Schedule.Cronjob.Entrypoint,
Arguments: job.CronJobResponse.Schedule.Cronjob.Arguments,
Entrypoint: job.CronJobResponse.Schedule.Cronjob.Entrypoint,
Arguments: job.CronJobResponse.Schedule.Cronjob.Arguments,
ScheduledAt: job.CronJobResponse.Schedule.Cronjob.ScheduledAt,
}

Expand Down

0 comments on commit c6639ba

Please sign in to comment.