From 9ee531c4d348c853a8ae6c5826ee58d33094521d Mon Sep 17 00:00:00 2001
From: "daniel.naude" <danieln@bob.co.za>
Date: Fri, 7 Jun 2024 08:16:00 +0200
Subject: [PATCH] Refactor BatchJob struct to use pointer for Name field

---
 batch/batch.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/batch/batch.go b/batch/batch.go
index b4d8ac3..5069ac3 100644
--- a/batch/batch.go
+++ b/batch/batch.go
@@ -34,7 +34,7 @@ type BatchJobQueue string
 type BatchJobMessageType string
 
 type BatchJob struct {
-	Name               string
+	Name               *string
 	Job                any
 	FullJobDefinition  string
 	FullJobQueue       string
@@ -60,10 +60,10 @@ func SubmitJob(batchJob BatchJob) error {
 
 	batchClient := batch.NewFromConfig(cfg)
 
-	if batchJob.Name == "" {
+	if batchJob.Name == nil {
 		id := uuid.New()
 		jobID := "job" + id.String()
-		batchJob.Name = jobID
+		batchJob.Name = utils.ValueToPointer(jobID)
 	}
 
 	err = uploadMessageToS3(batchJob)
@@ -73,7 +73,7 @@ func SubmitJob(batchJob BatchJob) error {
 
 	command := []string{
 		binaryPath,
-		batchJob.Name,
+		utils.PointerToValue(batchJob.Name),
 	}
 
 	environmentOverwrite := []types.KeyValuePair{{
@@ -84,7 +84,7 @@ func SubmitJob(batchJob BatchJob) error {
 
 	input := &batch.SubmitJobInput{
 		JobDefinition: utils.ValueToPointer(batchJob.FullJobDefinition),
-		JobName:       aws.String(batchJob.Name),
+		JobName:       batchJob.Name,
 		JobQueue:      aws.String(batchJob.FullJobQueue),
 		ContainerOverrides: &types.ContainerOverrides{
 			Command:     command,
@@ -106,7 +106,7 @@ func uploadMessageToS3(batchJob BatchJob) error {
 
 	// Upload message
 	_, err = s3.GetClient(batchJob.IsDebug).UploadWithSettingsRevised(jobBytes, batchJob.MessagesBucketName, s3.S3UploadSettings{
-		FileName: batchJob.Name,
+		FileName: utils.PointerToValue(batchJob.Name),
 	})
 	if err != nil {
 		return err
-- 
GitLab