Skip to content

Commit

Permalink
fix: improve readability
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Rodrigues <[email protected]>
  • Loading branch information
eduardodbr committed Nov 14, 2024
1 parent 31a73fd commit 4d59350
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
7 changes: 0 additions & 7 deletions workflow/common/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ func toWorkflow(cronWf wfv1.CronWorkflow, objectMeta metav1.ObjectMeta) *wfv1.Wo
}

wf.Labels[LabelKeyCronWorkflow] = cronWf.Name
if wf.Spec.WorkflowTemplateRef != nil {
if wf.Spec.WorkflowTemplateRef.ClusterScope {
wf.Labels[LabelKeyClusterWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
} else {
wf.Labels[LabelKeyWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
}
}
if cronWf.Spec.WorkflowMetadata != nil {
for key, label := range cronWf.Spec.WorkflowMetadata.Labels {
wf.Labels[key] = label
Expand Down
20 changes: 11 additions & 9 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4133,15 +4133,17 @@ func setWfPodNamesAnnotation(wf *wfv1.Workflow) {
}

func setWfTemplateLabel(wf *wfv1.Workflow) {
if wf.Spec.WorkflowTemplateRef != nil {
if wf.ObjectMeta.Labels == nil {
wf.ObjectMeta.Labels = map[string]string{}
}
if wf.Spec.WorkflowTemplateRef.ClusterScope {
wf.ObjectMeta.Labels[common.LabelKeyClusterWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
} else {
wf.ObjectMeta.Labels[common.LabelKeyWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
}
if wf.Spec.WorkflowTemplateRef == nil {
return
}
if wf.ObjectMeta.Labels == nil {
wf.ObjectMeta.Labels = map[string]string{}
}

if wf.Spec.WorkflowTemplateRef.ClusterScope {
wf.ObjectMeta.Labels[common.LabelKeyClusterWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
} else {
wf.ObjectMeta.Labels[common.LabelKeyWorkflowTemplate] = wf.Spec.WorkflowTemplateRef.Name
}
}

Expand Down

0 comments on commit 4d59350

Please sign in to comment.