feat: Rename the newSingleWorkflow function to Clone

Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
This commit is contained in:
Pascal Zimmermann authored and ZPascal committed 2026-06-17 17:49:13 +02:00
1 parent b33dfac0ac
commit 39bc278497
1 file changed
+4 -4
+4 -4
View File
@@ -109,7 +109,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
if placeholder.Name == "" { if placeholder.Name == "" {
placeholder.Name = id placeholder.Name = id
} }
swf := newSingleWorkflow(workflow) swf := workflow.Clone()
if err := swf.SetJob(id, placeholder); err != nil { if err := swf.SetJob(id, placeholder); err != nil {
return nil, fmt.Errorf("SetJob: %w", err) return nil, fmt.Errorf("SetJob: %w", err)
} }
@@ -125,7 +125,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
return nil, fmt.Errorf("getMatrixes: %w", err) return nil, fmt.Errorf("getMatrixes: %w", err)
} }
for _, matrix := range matricxes { for _, matrix := range matricxes {
swf := newSingleWorkflow(workflow) swf := workflow.Clone()
if err := swf.SetJob(id, expandJobCombo(id, job, matrix, evaluatedJob, pc.gitContext, results, pc.vars, pc.inputs)); err != nil { if err := swf.SetJob(id, expandJobCombo(id, job, matrix, evaluatedJob, pc.gitContext, results, pc.vars, pc.inputs)); err != nil {
return nil, fmt.Errorf("SetJob: %w", err) return nil, fmt.Errorf("SetJob: %w", err)
} }
@@ -135,8 +135,8 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
return ret, nil return ret, nil
} }
// newSingleWorkflow returns a SingleWorkflow carrying w's global fields and no job. // Clone returns a copy of w with its global fields but no jobs.
func newSingleWorkflow(w *SingleWorkflow) *SingleWorkflow { func (w *SingleWorkflow) Clone() *SingleWorkflow {
return &SingleWorkflow{ return &SingleWorkflow{
Name: w.Name, Name: w.Name,
RawOn: w.RawOn, RawOn: w.RawOn,