feat: Rename the newSingleWorkflow function to Clone

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