Merge pull request #12600 from zhongwencool/fix-schema-check
Fix bridge v2 and connector schema check
This commit is contained in:
commit
d34a1e9293
|
@ -98,9 +98,6 @@
|
||||||
|
|
||||||
-define(ROOT_KEY, bridges).
|
-define(ROOT_KEY, bridges).
|
||||||
|
|
||||||
%% See `hocon_tconf`
|
|
||||||
-define(MAP_KEY_RE, <<"^[A-Za-z0-9]+[A-Za-z0-9-_]*$">>).
|
|
||||||
|
|
||||||
load() ->
|
load() ->
|
||||||
Bridges = emqx:get_config([?ROOT_KEY], #{}),
|
Bridges = emqx:get_config([?ROOT_KEY], #{}),
|
||||||
emqx_utils:pforeach(
|
emqx_utils:pforeach(
|
||||||
|
|
|
@ -1596,12 +1596,14 @@ split_and_validate_bridge_v1_config(BridgeV1Type, BridgeName, RawConf, PreviousR
|
||||||
Output
|
Output
|
||||||
),
|
),
|
||||||
%% Validate the connector config and the bridge_v2 config
|
%% Validate the connector config and the bridge_v2 config
|
||||||
NewFakeGlobalConfig = #{
|
NewFakeConnectorConfig = #{
|
||||||
<<"connectors">> => #{
|
<<"connectors">> => #{
|
||||||
bin(ConnectorType) => #{
|
bin(ConnectorType) => #{
|
||||||
bin(ConnectorName) => NewConnectorRawConf
|
bin(ConnectorName) => NewConnectorRawConf
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
NewFakeBridgeV2Config = #{
|
||||||
ConfRootKey => #{
|
ConfRootKey => #{
|
||||||
bin(BridgeV2Type) => #{
|
bin(BridgeV2Type) => #{
|
||||||
bin(BridgeName) => NewBridgeV2RawConf
|
bin(BridgeName) => NewBridgeV2RawConf
|
||||||
|
@ -1609,9 +1611,14 @@ split_and_validate_bridge_v1_config(BridgeV1Type, BridgeName, RawConf, PreviousR
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
try
|
try
|
||||||
hocon_tconf:check_plain(
|
_ = hocon_tconf:check_plain(
|
||||||
emqx_schema,
|
emqx_connector_schema,
|
||||||
NewFakeGlobalConfig,
|
NewFakeConnectorConfig,
|
||||||
|
#{atom_key => false, required => false}
|
||||||
|
),
|
||||||
|
_ = hocon_tconf:check_plain(
|
||||||
|
emqx_bridge_v2_schema,
|
||||||
|
NewFakeBridgeV2Config,
|
||||||
#{atom_key => false, required => false}
|
#{atom_key => false, required => false}
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
|
@ -1627,8 +1634,10 @@ split_and_validate_bridge_v1_config(BridgeV1Type, BridgeName, RawConf, PreviousR
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
%% validation errors
|
%% validation errors
|
||||||
|
throw:{_Module, [Reason1 | _]} ->
|
||||||
|
throw(Reason1);
|
||||||
throw:Reason1 ->
|
throw:Reason1 ->
|
||||||
{error, Reason1}
|
throw(Reason1)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_conf_root_key(#{<<"actions">> := _}) ->
|
get_conf_root_key(#{<<"actions">> := _}) ->
|
||||||
|
|
|
@ -154,7 +154,9 @@
|
||||||
%% boolean
|
%% boolean
|
||||||
-define(START_AFTER_CREATED, true).
|
-define(START_AFTER_CREATED, true).
|
||||||
|
|
||||||
-define(TEST_ID_PREFIX, "_probe_:").
|
%% Keep this test_id_prefix is match "^[A-Za-z0-9]+[A-Za-z0-9-_]*$".
|
||||||
|
%% See `hocon_tconf`
|
||||||
|
-define(TEST_ID_PREFIX, "t_probe_").
|
||||||
-define(RES_METRICS, resource_metrics).
|
-define(RES_METRICS, resource_metrics).
|
||||||
|
|
||||||
-define(RESOURCE_ALLOCATION_TAB, emqx_resource_allocations).
|
-define(RESOURCE_ALLOCATION_TAB, emqx_resource_allocations).
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
get_allocated_resources/1,
|
get_allocated_resources/1,
|
||||||
get_allocated_resources_list/1,
|
get_allocated_resources_list/1,
|
||||||
forget_allocated_resources/1,
|
forget_allocated_resources/1,
|
||||||
|
deallocate_resource/2,
|
||||||
%% Get channel config from resource
|
%% Get channel config from resource
|
||||||
call_get_channel_config/3
|
call_get_channel_config/3
|
||||||
]).
|
]).
|
||||||
|
@ -650,6 +651,10 @@ forget_allocated_resources(InstanceId) ->
|
||||||
true = ets:delete(?RESOURCE_ALLOCATION_TAB, InstanceId),
|
true = ets:delete(?RESOURCE_ALLOCATION_TAB, InstanceId),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
deallocate_resource(InstanceId, Key) ->
|
||||||
|
true = ets:match_delete(?RESOURCE_ALLOCATION_TAB, {InstanceId, Key, '_'}),
|
||||||
|
ok.
|
||||||
|
|
||||||
-spec create_metrics(resource_id()) -> ok.
|
-spec create_metrics(resource_id()) -> ok.
|
||||||
create_metrics(ResId) ->
|
create_metrics(ResId) ->
|
||||||
emqx_metrics_worker:create_metrics(
|
emqx_metrics_worker:create_metrics(
|
||||||
|
|
Loading…
Reference in New Issue