Просмотр исходного кода

fix(ft): make ee schema aware of ee fields

Ilya Averyanov 3 лет назад
Родитель
Сommit
2f1970adbc

+ 4 - 1
apps/emqx_ft/src/emqx_ft_schema.erl

@@ -35,7 +35,7 @@
 
 -reflect_type([json_value/0]).
 
--import(hoconsc, [ref/1, ref/2, mk/2]).
+-import(hoconsc, [ref/2, mk/2]).
 
 namespace() -> file_transfer.
 
@@ -217,3 +217,6 @@ converter(checksum) ->
             _ = byte_size(Hex) =:= 64 orelse throw({expected_length, 64}),
             {sha256, binary:decode_hex(Hex)}
     end.
+
+ref(Ref) ->
+    ref(?MODULE, Ref).

+ 15 - 1
lib-ee/emqx_ee_conf/src/emqx_ee_conf_schema.erl

@@ -26,10 +26,24 @@ roots() ->
     ).
 
 fields(Name) ->
-    emqx_conf_schema:fields(Name).
+    ee_fields(?EE_SCHEMA_MODULES, Name).
 
 translations() ->
     emqx_conf_schema:translations().
 
 translation(Name) ->
     emqx_conf_schema:translation(Name).
+
+%%------------------------------------------------------------------------------
+%% helpers
+%%------------------------------------------------------------------------------
+
+ee_fields([EEMod | EEMods], Name) ->
+    case lists:member(Name, apply(EEMod, roots, [])) of
+        true ->
+            apply(EEMod, fields, [Name]);
+        false ->
+            ee_fields(EEMods, Name)
+    end;
+ee_fields([], Name) ->
+    emqx_conf_schema:fields(Name).