Skip to content

Commit

Permalink
[Workflows] Order job name alphabetically
Browse files Browse the repository at this point in the history
Usually directories are ordered alphabetically when we access to them
via CLI or UI.
With this change the alphabetical order corresponds with the workflow
order.
  • Loading branch information
eduolivares committed Nov 18, 2024
1 parent 1f917b1 commit 51044c9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
const (
workflowNameSuffix = "-workflow-counter"
jobNameStepInfix = "-workflow-step-"
logDirNameInfix = "-workflow-step-"
envVarsConfigMapinfix = "-env-vars-step-"
customDataConfigMapinfix = "-custom-data-step-"
workflowStepNumInvalid = -1
Expand Down Expand Up @@ -178,7 +177,7 @@ func (r *Reconciler) GetJobName(instance interface{}, workflowStepNum int) strin
workflowStepName = typedInstance.Spec.Workflow[workflowStepNum].StepName
}

return typedInstance.Name + "-" + workflowStepName + jobNameStepInfix + strconv.Itoa(workflowStepNum)
return typedInstance.Name + jobNameStepInfix + fmt.Sprintf("%02d", workflowStepNum) + "-" + workflowStepName
} else if typedInstance, ok := instance.(*v1beta1.Tempest); ok {
if len(typedInstance.Spec.Workflow) == 0 || workflowStepNum == workflowStepNumInvalid {
return typedInstance.Name
Expand All @@ -189,7 +188,7 @@ func (r *Reconciler) GetJobName(instance interface{}, workflowStepNum int) strin
workflowStepName = typedInstance.Spec.Workflow[workflowStepNum].StepName
}

return typedInstance.Name + "-" + workflowStepName + jobNameStepInfix + strconv.Itoa(workflowStepNum)
return typedInstance.Name + jobNameStepInfix + fmt.Sprintf("%02d", workflowStepNum) + "-" + workflowStepName
} else if typedInstance, ok := instance.(*v1beta1.HorizonTest); ok {
return typedInstance.Name
} else if typedInstance, ok := instance.(*v1beta1.AnsibleTest); ok {
Expand All @@ -202,7 +201,7 @@ func (r *Reconciler) GetJobName(instance interface{}, workflowStepNum int) strin
workflowStepName = typedInstance.Spec.Workflow[workflowStepNum].StepName
}

return typedInstance.Name + "-" + workflowStepName + jobNameStepInfix + strconv.Itoa(workflowStepNum)
return typedInstance.Name + jobNameStepInfix + fmt.Sprintf("%02d", workflowStepNum) + "-" + workflowStepName
}

return workflowStepNameInvalid
Expand Down

0 comments on commit 51044c9

Please sign in to comment.