fix(actions_api): fill raw config defaults before returning
Fixes https://emqx.atlassian.net/browse/EMQX-11541
This commit is contained in:
parent
8a5b0d252d
commit
2757b95850
|
@ -799,11 +799,12 @@ format_resource(
|
|||
name := Name,
|
||||
status := Status,
|
||||
error := Error,
|
||||
raw_config := RawConf,
|
||||
raw_config := RawConf0,
|
||||
resource_data := _ResourceData
|
||||
},
|
||||
Node
|
||||
) ->
|
||||
RawConf = fill_defaults(Type, RawConf0),
|
||||
redact(
|
||||
maps:merge(
|
||||
RawConf#{
|
||||
|
@ -934,6 +935,20 @@ aggregate_metrics(
|
|||
M17 + N17
|
||||
).
|
||||
|
||||
fill_defaults(Type, RawConf) ->
|
||||
PackedConf = pack_bridge_conf(Type, RawConf),
|
||||
FullConf = emqx_config:fill_defaults(emqx_bridge_v2_schema, PackedConf, #{}),
|
||||
unpack_bridge_conf(Type, FullConf).
|
||||
|
||||
pack_bridge_conf(Type, RawConf) ->
|
||||
#{<<"actions">> => #{bin(Type) => #{<<"foo">> => RawConf}}}.
|
||||
|
||||
unpack_bridge_conf(Type, PackedConf) ->
|
||||
TypeBin = bin(Type),
|
||||
#{<<"actions">> := Bridges} = PackedConf,
|
||||
#{<<"foo">> := RawConf} = maps:get(TypeBin, Bridges),
|
||||
RawConf.
|
||||
|
||||
format_bridge_status_and_error(Data) ->
|
||||
maps:fold(fun format_resource_data/3, #{}, maps:with([status, error], Data)).
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ t_bridges_lifecycle(Config) ->
|
|||
<<"status">> := <<"connected">>,
|
||||
<<"node_status">> := [_ | _],
|
||||
<<"connector">> := ?CONNECTOR_NAME,
|
||||
<<"kafka">> := #{},
|
||||
<<"parameters">> := #{},
|
||||
<<"local_topic">> := _,
|
||||
<<"resource_opts">> := _
|
||||
}},
|
||||
|
@ -1138,6 +1138,19 @@ t_cluster_later_join_metrics(Config) ->
|
|||
),
|
||||
ok.
|
||||
|
||||
t_raw_config_response_defaults(Config) ->
|
||||
Params = maps:remove(<<"enable">>, ?KAFKA_BRIDGE(?BRIDGE_NAME)),
|
||||
?assertMatch(
|
||||
{ok, 201, #{<<"enable">> := true}},
|
||||
request_json(
|
||||
post,
|
||||
uri([?ROOT]),
|
||||
Params,
|
||||
Config
|
||||
)
|
||||
),
|
||||
ok.
|
||||
|
||||
%%% helpers
|
||||
listen_on_random_port() ->
|
||||
SockOpts = [binary, {active, false}, {packet, raw}, {reuseaddr, true}, {backlog, 1000}],
|
||||
|
|
|
@ -766,7 +766,7 @@ t_actions_field(Config) ->
|
|||
<<"status">> := <<"connected">>,
|
||||
<<"node_status">> := [_ | _],
|
||||
<<"connector">> := Name,
|
||||
<<"kafka">> := #{},
|
||||
<<"parameters">> := #{},
|
||||
<<"local_topic">> := _,
|
||||
<<"resource_opts">> := _
|
||||
}},
|
||||
|
@ -821,7 +821,7 @@ t_fail_delete_with_action(Config) ->
|
|||
<<"status">> := <<"connected">>,
|
||||
<<"node_status">> := [_ | _],
|
||||
<<"connector">> := Name,
|
||||
<<"kafka">> := #{},
|
||||
<<"parameters">> := #{},
|
||||
<<"local_topic">> := _,
|
||||
<<"resource_opts">> := _
|
||||
}},
|
||||
|
|
Loading…
Reference in New Issue