Skip to content
Snippets Groups Projects
Commit 9ee531c4 authored by Daniel Naude's avatar Daniel Naude
Browse files

Refactor BatchJob struct to use pointer for Name field

parent c0c2e5bd
Branches
Tags
1 merge request!48Migrate to aws sdk for go v2
...@@ -34,7 +34,7 @@ type BatchJobQueue string ...@@ -34,7 +34,7 @@ type BatchJobQueue string
type BatchJobMessageType string type BatchJobMessageType string
type BatchJob struct { type BatchJob struct {
Name string Name *string
Job any Job any
FullJobDefinition string FullJobDefinition string
FullJobQueue string FullJobQueue string
...@@ -60,10 +60,10 @@ func SubmitJob(batchJob BatchJob) error { ...@@ -60,10 +60,10 @@ func SubmitJob(batchJob BatchJob) error {
batchClient := batch.NewFromConfig(cfg) batchClient := batch.NewFromConfig(cfg)
if batchJob.Name == "" { if batchJob.Name == nil {
id := uuid.New() id := uuid.New()
jobID := "job" + id.String() jobID := "job" + id.String()
batchJob.Name = jobID batchJob.Name = utils.ValueToPointer(jobID)
} }
err = uploadMessageToS3(batchJob) err = uploadMessageToS3(batchJob)
...@@ -73,7 +73,7 @@ func SubmitJob(batchJob BatchJob) error { ...@@ -73,7 +73,7 @@ func SubmitJob(batchJob BatchJob) error {
command := []string{ command := []string{
binaryPath, binaryPath,
batchJob.Name, utils.PointerToValue(batchJob.Name),
} }
environmentOverwrite := []types.KeyValuePair{{ environmentOverwrite := []types.KeyValuePair{{
...@@ -84,7 +84,7 @@ func SubmitJob(batchJob BatchJob) error { ...@@ -84,7 +84,7 @@ func SubmitJob(batchJob BatchJob) error {
input := &batch.SubmitJobInput{ input := &batch.SubmitJobInput{
JobDefinition: utils.ValueToPointer(batchJob.FullJobDefinition), JobDefinition: utils.ValueToPointer(batchJob.FullJobDefinition),
JobName: aws.String(batchJob.Name), JobName: batchJob.Name,
JobQueue: aws.String(batchJob.FullJobQueue), JobQueue: aws.String(batchJob.FullJobQueue),
ContainerOverrides: &types.ContainerOverrides{ ContainerOverrides: &types.ContainerOverrides{
Command: command, Command: command,
...@@ -106,7 +106,7 @@ func uploadMessageToS3(batchJob BatchJob) error { ...@@ -106,7 +106,7 @@ func uploadMessageToS3(batchJob BatchJob) error {
// Upload message // Upload message
_, err = s3.GetClient(batchJob.IsDebug).UploadWithSettingsRevised(jobBytes, batchJob.MessagesBucketName, s3.S3UploadSettings{ _, err = s3.GetClient(batchJob.IsDebug).UploadWithSettingsRevised(jobBytes, batchJob.MessagesBucketName, s3.S3UploadSettings{
FileName: batchJob.Name, FileName: utils.PointerToValue(batchJob.Name),
}) })
if err != nil { if err != nil {
return err return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment