From 61e46760d63d5da56eaa5db1da9acc2002ae08da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 22:45:43 +0000 Subject: [PATCH] Consolidate workflow edge connection construction Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- workflow/builder.go | 17 ++++------------- workflow/edge.go | 7 +++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/workflow/builder.go b/workflow/builder.go index 358816d8..ac6d3d44 100644 --- a/workflow/builder.go +++ b/workflow/builder.go @@ -122,10 +122,7 @@ func (wb *Builder) AddDirectEdge(source ExecutorBinding, target ExecutorBinding, if wb.err != nil { return wb } - conn := EdgeConnection{ - SourceIDs: []string{source.ID}, - SinkIDs: []string{target.ID}, - } + conn := newEdgeConnection([]string{source.ID}, []string{target.ID}) if condition == nil && slices.ContainsFunc(wb.conditionlessConnections, func(c EdgeConnection) bool { return conn.Equal(c) }) { @@ -167,10 +164,7 @@ func (wb *Builder) AddFanOutEdge(source ExecutorBinding, targets []ExecutorBindi } sinkIDs = append(sinkIDs, target.ID) } - conn := EdgeConnection{ - SourceIDs: []string{source.ID}, - SinkIDs: sinkIDs, - } + conn := newEdgeConnection([]string{source.ID}, sinkIDs) edge := Edge{ Connection: conn, Index: wb.edgeIdx(), @@ -197,11 +191,8 @@ func (wb *Builder) AddFanInBarrierEdge(sources []ExecutorBinding, target Executo sourceIDs = append(sourceIDs, source.ID) } edge := Edge{ - Connection: EdgeConnection{ - SourceIDs: sourceIDs, - SinkIDs: []string{target.ID}, - }, - Index: wb.edgeIdx(), + Connection: newEdgeConnection(sourceIDs, []string{target.ID}), + Index: wb.edgeIdx(), } applyEdgeOptions(&edge, opts) for _, id := range sourceIDs { diff --git a/workflow/edge.go b/workflow/edge.go index e3fe73b1..863032aa 100644 --- a/workflow/edge.go +++ b/workflow/edge.go @@ -79,6 +79,13 @@ type EdgeConnection struct { SinkIDs []string } +func newEdgeConnection(sourceIDs []string, sinkIDs []string) EdgeConnection { + return EdgeConnection{ + SourceIDs: sourceIDs, + SinkIDs: sinkIDs, + } +} + func (c EdgeConnection) Equal(other EdgeConnection) bool { return slices.Equal(c.SourceIDs, other.SourceIDs) && slices.Equal(c.SinkIDs, other.SinkIDs) }