summaryrefslogtreecommitdiff
path: root/src/marlin.core/models/meta/Recipe.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
commitdf0737e55afeb5c01eb39909605970d1d3a73ffc (patch)
tree09823eaa310c60eefd2420dc305acae45c81900f /src/marlin.core/models/meta/Recipe.cs
parentee69ce25b2fba871920260028bb10c2d6b62b26f (diff)
refactor: cleanup; feat: connection to agent
Diffstat (limited to 'src/marlin.core/models/meta/Recipe.cs')
-rw-r--r--src/marlin.core/models/meta/Recipe.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/marlin.core/models/meta/Recipe.cs b/src/marlin.core/models/meta/Recipe.cs
new file mode 100644
index 0000000..33ed814
--- /dev/null
+++ b/src/marlin.core/models/meta/Recipe.cs
@@ -0,0 +1,36 @@
+namespace marlin.core.models.meta;
+
+public class Recipe
+{
+ public Recipe(string id)
+ {
+ this.Id = id;
+ }
+
+ public string Id { get; }
+ public string Name { get; set; }
+
+ public string? RunsOnId { get; set; }
+ public List<string> RequireIds { get; set; } = [];
+ public Dictionary<string, RecipeStep> Steps { get; set; } = new();
+ public Dictionary<string, string> Parameters { get; set; } = new();
+ public Dictionary<string, string> Environment { get; set; } = new();
+
+ public RequirementSet? GetRunsOn(Workflow workflow) =>
+ this.RunsOnId != null ? workflow.Requirements[this.RunsOnId] : null;
+
+ public IEnumerable<Recipe> GetRequires(Workflow workflow) =>
+ this.RequireIds.Select(id => workflow.Recipes[id]);
+
+ public Dictionary<string, string> CreateArguments()
+ {
+ Dictionary<string, string> args = new();
+ foreach (var parameter in this.Parameters)
+ args.Add(parameter.Key, parameter.Value);
+
+ foreach (var environment in this.Environment)
+ args.Add($"env.{environment.Key}", environment.Value);
+
+ return args;
+ }
+}