fix: allow Type in resource-id and pass it on
This commit is contained in:
parent
8567ccafc1
commit
f3648c5232
|
@ -241,11 +241,11 @@ recreate(Type, Name, Conf, Opts) ->
|
|||
).
|
||||
|
||||
create_dry_run(Type, Conf0) ->
|
||||
TmpName = iolist_to_binary([?TEST_ID_PREFIX, emqx_utils:gen_id(8)]),
|
||||
TmpPath = emqx_utils:safe_filename(TmpName),
|
||||
%% Already typechecked, no need to catch errors
|
||||
TypeBin = bin(Type),
|
||||
TypeAtom = safe_atom(Type),
|
||||
TmpName = iolist_to_binary([?TEST_ID_PREFIX, TypeBin, ":", emqx_utils:gen_id(8)]),
|
||||
TmpPath = emqx_utils:safe_filename(TmpName),
|
||||
Conf1 = maps:without([<<"name">>], Conf0),
|
||||
RawConf = #{<<"connectors">> => #{TypeBin => #{<<"temp_name">> => Conf1}}},
|
||||
try
|
||||
|
@ -260,7 +260,9 @@ create_dry_run(Type, Conf0) ->
|
|||
{error, Reason};
|
||||
{ok, ConfNew} ->
|
||||
ParseConf = parse_confs(bin(Type), TmpName, ConfNew),
|
||||
emqx_resource:create_dry_run_local(connector_to_resource_type(Type), ParseConf)
|
||||
emqx_resource:create_dry_run_local(
|
||||
TmpName, connector_to_resource_type(Type), ParseConf
|
||||
)
|
||||
end
|
||||
catch
|
||||
%% validation errors
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
%% run start/2, health_check/2 and stop/1 sequentially
|
||||
create_dry_run/2,
|
||||
create_dry_run_local/2,
|
||||
create_dry_run_local/3,
|
||||
%% this will do create_dry_run, stop the old instance and start a new one
|
||||
recreate/3,
|
||||
recreate/4,
|
||||
|
@ -292,6 +293,9 @@ create_dry_run(ResourceType, Config) ->
|
|||
create_dry_run_local(ResourceType, Config) ->
|
||||
emqx_resource_manager:create_dry_run(ResourceType, Config).
|
||||
|
||||
create_dry_run_local(ResId, ResourceType, Config) ->
|
||||
emqx_resource_manager:create_dry_run(ResId, ResourceType, Config).
|
||||
|
||||
-spec recreate(resource_id(), resource_type(), resource_config()) ->
|
||||
{ok, resource_data()} | {error, Reason :: term()}.
|
||||
recreate(ResId, ResourceType, Config) ->
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
recreate/4,
|
||||
remove/1,
|
||||
create_dry_run/2,
|
||||
create_dry_run/3,
|
||||
restart/2,
|
||||
start/2,
|
||||
stop/1,
|
||||
|
@ -159,6 +160,9 @@ create(ResId, Group, ResourceType, Config, Opts) ->
|
|||
ok | {error, Reason :: term()}.
|
||||
create_dry_run(ResourceType, Config) ->
|
||||
ResId = make_test_id(),
|
||||
create_dry_run(ResId, ResourceType, Config).
|
||||
|
||||
create_dry_run(ResId, ResourceType, Config) ->
|
||||
Opts =
|
||||
case is_map(Config) of
|
||||
true -> maps:get(resource_opts, Config, #{});
|
||||
|
|
Loading…
Reference in New Issue