diff --git a/lib/wanda/executions/server.ex b/lib/wanda/executions/server.ex index 82b657be..6c878a54 100644 --- a/lib/wanda/executions/server.ex +++ b/lib/wanda/executions/server.ex @@ -37,9 +37,8 @@ defmodule Wanda.Executions.Server do If non-existing check IDs are provided inside a target, they will get filtered away. """ @impl true - def start_execution(execution_id, group_id, targets, env, config \\ []) do - # TODO: this should be removed when web properly sets the target type in ExecutionRequested event - env = Map.put(env, "target_type", @default_target_type) + def start_execution(execution_id, group_id, targets, target_type, env, config \\ []) do + env = Map.put(env, "target_type", target_type) checks = targets diff --git a/lib/wanda/executions/server_behaviour.ex b/lib/wanda/executions/server_behaviour.ex index 2b71f6c9..44b40c75 100644 --- a/lib/wanda/executions/server_behaviour.ex +++ b/lib/wanda/executions/server_behaviour.ex @@ -9,6 +9,7 @@ defmodule Wanda.Executions.ServerBehaviour do execution_id :: String.t(), group_id :: String.t(), targets :: [Target.t()], + target_type :: String.t(), env :: %{String.t() => boolean() | number() | String.t()} ) :: :ok | {:error, :no_checks_selected} | {:error, :already_running} @@ -16,6 +17,7 @@ defmodule Wanda.Executions.ServerBehaviour do execution_id :: String.t(), group_id :: String.t(), targets :: [Target.t()], + target_type :: String.t(), env :: %{String.t() => boolean() | number() | String.t()}, config :: Keyword.t() ) :: :ok | {:error, any} diff --git a/lib/wanda/messaging/mapper.ex b/lib/wanda/messaging/mapper.ex index 0c38a65a..61999971 100644 --- a/lib/wanda/messaging/mapper.ex +++ b/lib/wanda/messaging/mapper.ex @@ -59,18 +59,21 @@ defmodule Wanda.Messaging.Mapper do execution_id: String.t(), group_id: String.t(), targets: [Target.t()], + target_type: String.t(), env: %{String.t() => boolean() | number() | String.t() | nil} } def from_execution_requested(%ExecutionRequested{ execution_id: execution_id, group_id: group_id, targets: targets, + target_type: target_type, env: env }) do %{ execution_id: execution_id, group_id: group_id, targets: Target.map_targets(targets), + target_type: target_type, env: Map.new(env, fn {key, %{kind: value}} -> {key, map_env_entry(value)} end) } end diff --git a/lib/wanda/policy.ex b/lib/wanda/policy.ex index 8f504a8c..a9ee396b 100644 --- a/lib/wanda/policy.ex +++ b/lib/wanda/policy.ex @@ -20,13 +20,19 @@ defmodule Wanda.Policy do end defp handle(%ExecutionRequested{} = message) do - %{execution_id: execution_id, group_id: group_id, targets: targets, env: env} = - Mapper.from_execution_requested(message) + %{ + execution_id: execution_id, + group_id: group_id, + targets: targets, + env: env, + target_type: target_type + } = Mapper.from_execution_requested(message) execution_server_impl().start_execution( execution_id, group_id, targets, + target_type, env ) end