mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: copy tenant to step on flow build (#603)
This commit is contained in:
parent
c4bb198d0c
commit
5b6c81d800
1 changed files with 12 additions and 8 deletions
|
@ -17,12 +17,12 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
defstruct [:steps, :flow, :returns]
|
defstruct [:steps, :flow, :returns]
|
||||||
end
|
end
|
||||||
|
|
||||||
def build(flow, input, _opts) do
|
def build(flow, input, opts) do
|
||||||
steps =
|
steps =
|
||||||
flow
|
flow
|
||||||
|> Ash.Flow.Info.steps()
|
|> Ash.Flow.Info.steps()
|
||||||
|> to_steps(input)
|
|> to_steps(input, opts)
|
||||||
|> hydrate_flows()
|
|> hydrate_flows(opts)
|
||||||
|
|
||||||
{:ok,
|
{:ok,
|
||||||
%Flow{
|
%Flow{
|
||||||
|
@ -32,7 +32,7 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp to_steps(steps, input) do
|
defp to_steps(steps, input, opts) do
|
||||||
Enum.map(steps, fn step ->
|
Enum.map(steps, fn step ->
|
||||||
step =
|
step =
|
||||||
case step do
|
case step do
|
||||||
|
@ -48,7 +48,10 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
step
|
step
|
||||||
end
|
end
|
||||||
|
|
||||||
%{step | steps: to_steps(steps, input)}
|
%{step | steps: to_steps(steps, input, opts)}
|
||||||
|
|
||||||
|
%{tenant: _tenant} = step ->
|
||||||
|
%{step | tenant: Keyword.get(opts, :tenant)}
|
||||||
|
|
||||||
step ->
|
step ->
|
||||||
step
|
step
|
||||||
|
@ -58,7 +61,7 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hydrate_flows(steps) do
|
defp hydrate_flows(steps, opts) do
|
||||||
Enum.flat_map(steps, fn
|
Enum.flat_map(steps, fn
|
||||||
%Step{
|
%Step{
|
||||||
input: input,
|
input: input,
|
||||||
|
@ -71,7 +74,7 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
}
|
}
|
||||||
} = run_flow_step ->
|
} = run_flow_step ->
|
||||||
{run_flow_input, _} = Ash.Flow.Template.handle_input_template(run_flow_input, input)
|
{run_flow_input, _} = Ash.Flow.Template.handle_input_template(run_flow_input, input)
|
||||||
{:ok, %{steps: hydrated_steps}} = build(flow, run_flow_input, [])
|
{:ok, %{steps: hydrated_steps}} = build(flow, run_flow_input, opts)
|
||||||
|
|
||||||
built_steps =
|
built_steps =
|
||||||
hydrated_steps
|
hydrated_steps
|
||||||
|
@ -119,7 +122,8 @@ defmodule Ash.Flow.Executor.AshEngine do
|
||||||
|> handle_input_templates()
|
|> handle_input_templates()
|
||||||
|
|
||||||
%Step{step: %{steps: steps} = inner_step} = step ->
|
%Step{step: %{steps: steps} = inner_step} = step ->
|
||||||
[%{step | step: %{inner_step | steps: hydrate_flows(steps)}}] |> handle_input_templates()
|
[%{step | step: %{inner_step | steps: hydrate_flows(steps, opts)}}]
|
||||||
|
|> handle_input_templates()
|
||||||
|
|
||||||
step ->
|
step ->
|
||||||
[step] |> handle_input_templates()
|
[step] |> handle_input_templates()
|
||||||
|
|
Loading…
Reference in a new issue