summaryrefslogtreecommitdiff
path: root/src/marlin.core/models/meta/RecipeStep.cs
blob: 5cb1f786618844bc566e8581bf68c7e1c21bfbcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace marlin.core.models.meta;

public class RecipeStep : AbstractStep
{
    public RecipeStep(string id) : base(id)
    {
    }

    public string? BaseId { get; set; }
    public CleanupStep? Cleanup { get; set; }
    public Dictionary<string, string> Artifacts { get; set; } = new();

    public RecipeStep? GetBase(Workflow workflow) =>
        this.BaseId != null ? workflow.Steps[this.BaseId] : null;

    public override IEnumerable<AbstractStep> GetAncestorsAndThis(Workflow workflow)
    {
        yield return this;

        var step = this.GetBase(workflow);
        while (step != null)
        {
            yield return step;
            step = step.GetBase(workflow);
        }
    }
}