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

fix(mgmt): remove schema_registry calls from opensource code

Shawn 5 лет назад
Родитель
Сommit
12e0028b77

+ 2 - 2
Makefile

@@ -20,11 +20,11 @@ ensure-rebar3:
 $(REBAR): ensure-rebar3
 $(REBAR): ensure-rebar3
 
 
 .PHONY: xref
 .PHONY: xref
-xref:
+xref: $(REBAR)
 	$(REBAR) xref
 	$(REBAR) xref
 
 
 .PHONY: dialyzer
 .PHONY: dialyzer
-dialyzer:
+dialyzer: $(REBAR)
 	$(REBAR) dialyzer
 	$(REBAR) dialyzer
 
 
 .PHONY: distclean
 .PHONY: distclean

+ 1 - 16
apps/emqx_management/src/emqx_mgmt.erl

@@ -128,7 +128,6 @@
         , export_auth_username/0
         , export_auth_username/0
         , export_auth_mnesia/0
         , export_auth_mnesia/0
         , export_acl_mnesia/0
         , export_acl_mnesia/0
-        , export_schemas/0
         , import_rules/1
         , import_rules/1
         , import_resources/1
         , import_resources/1
         , import_blacklist/1
         , import_blacklist/1
@@ -138,7 +137,6 @@
         , import_auth_username/1
         , import_auth_username/1
         , import_auth_mnesia/1
         , import_auth_mnesia/1
         , import_acl_mnesia/1
         , import_acl_mnesia/1
-        , import_schemas/1
         , to_version/1
         , to_version/1
         ]).
         ]).
 
 
@@ -679,13 +677,6 @@ export_acl_mnesia() ->
                         end, [], ets:tab2list(emqx_acl))
                         end, [], ets:tab2list(emqx_acl))
     end.
     end.
 
 
-export_schemas() ->
-    case ets:info(emqx_schema) of
-        undefined -> [];
-        _ ->
-            [emqx_schema_api:format_schema(Schema) || Schema <- emqx_schema_registry:get_all_schemas()]
-    end.
-
 import_rules(Rules) ->
 import_rules(Rules) ->
     lists:foreach(fun(#{<<"id">> := RuleId,
     lists:foreach(fun(#{<<"id">> := RuleId,
                         <<"rawsql">> := RawSQL,
                         <<"rawsql">> := RawSQL,
@@ -788,19 +779,13 @@ import_auth_mnesia(Auths) ->
 import_acl_mnesia(Acls) ->
 import_acl_mnesia(Acls) ->
     case ets:info(emqx_acl) of
     case ets:info(emqx_acl) of
         undefined -> ok;
         undefined -> ok;
-        _ -> 
+        _ ->
             [ mnesia:dirty_write({emqx_acl ,Login, Topic, Action, Allow}) || #{<<"login">> := Login, 
             [ mnesia:dirty_write({emqx_acl ,Login, Topic, Action, Allow}) || #{<<"login">> := Login, 
                                                                                <<"topic">> := Topic,
                                                                                <<"topic">> := Topic,
                                                                                <<"action">> := Action,
                                                                                <<"action">> := Action,
                                                                                <<"allow">> := Allow} <- Acls ]
                                                                                <<"allow">> := Allow} <- Acls ]
     end.
     end.
 
 
-import_schemas(Schemas) -> 
-    case ets:info(emqx_schema) of
-        undefined -> ok;
-        _ -> [emqx_schema_registry:add_schema(emqx_schema_api:make_schema_params(Schema)) || Schema <- Schemas]
-    end.
-
 any_to_atom(L) when is_list(L) -> list_to_atom(L);
 any_to_atom(L) when is_list(L) -> list_to_atom(L);
 any_to_atom(B) when is_binary(B) -> binary_to_atom(B, utf8);
 any_to_atom(B) when is_binary(B) -> binary_to_atom(B, utf8);
 any_to_atom(A) when is_atom(A) -> A.
 any_to_atom(A) when is_atom(A) -> A.

+ 6 - 9
apps/emqx_management/src/emqx_mgmt_api_data.erl

@@ -84,7 +84,6 @@ export(_Bindings, _Params) ->
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
-    Schemas = emqx_mgmt:export_schemas(),
     Seconds = erlang:system_time(second),
     Seconds = erlang:system_time(second),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
@@ -100,8 +99,7 @@ export(_Bindings, _Params) ->
             {auth_clientid, AuthClientid},
             {auth_clientid, AuthClientid},
             {auth_username, AuthUsername},
             {auth_username, AuthUsername},
             {auth_mnesia, AuthMnesia},
             {auth_mnesia, AuthMnesia},
-            {acl_mnesia, AclMnesia},
-            {schemas, Schemas}
+            {acl_mnesia, AclMnesia}
            ],
            ],
 
 
     Bin = emqx_json:encode(Data),
     Bin = emqx_json:encode(Data),
@@ -180,20 +178,19 @@ do_import(Filename) ->
             case lists:member(Version, ?VERSIONS) of
             case lists:member(Version, ?VERSIONS) of
                 true  ->
                 true  ->
                     try
                     try
-                        emqx_mgmt:import_confs(maps:get(<<"configs">>, Data, []), maps:get(<<"listeners_state">>, Data, [])),
+                        %emqx_mgmt:import_confs(maps:get(<<"configs">>, Data, []), maps:get(<<"listeners_state">>, Data, [])),
                         emqx_mgmt:import_resources(maps:get(<<"resources">>, Data, [])),
                         emqx_mgmt:import_resources(maps:get(<<"resources">>, Data, [])),
                         emqx_mgmt:import_rules(maps:get(<<"rules">>, Data, [])),
                         emqx_mgmt:import_rules(maps:get(<<"rules">>, Data, [])),
                         emqx_mgmt:import_blacklist(maps:get(<<"blacklist">>, Data, [])),
                         emqx_mgmt:import_blacklist(maps:get(<<"blacklist">>, Data, [])),
                         emqx_mgmt:import_applications(maps:get(<<"apps">>, Data, [])),
                         emqx_mgmt:import_applications(maps:get(<<"apps">>, Data, [])),
                         emqx_mgmt:import_users(maps:get(<<"users">>, Data, [])),
                         emqx_mgmt:import_users(maps:get(<<"users">>, Data, [])),
-                        emqx_mgmt:import_modules(maps:get(<<"modules">>, Data, [])),
+                        %emqx_mgmt:import_modules(maps:get(<<"modules">>, Data, [])),
                         emqx_mgmt:import_auth_clientid(maps:get(<<"auth_clientid">>, Data, [])),
                         emqx_mgmt:import_auth_clientid(maps:get(<<"auth_clientid">>, Data, [])),
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
-                        emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, []), Version),
-                        emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, []), Version),
-                        emqx_mgmt:import_schemas(maps:get(<<"schemas">>, Data, [])),
+                        %emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, []), Version),
+                        %emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, []), Version),
                         logger:debug("The emqx data has been imported successfully"),
                         logger:debug("The emqx data has been imported successfully"),
-                        ok
+                        error({not_implemented, [import_confs,import_modules,import_auth_mnesia,import_acl_mnesia]})
                     catch Class:Reason:Stack ->
                     catch Class:Reason:Stack ->
                         logger:error("The emqx data import failed: ~0p", [{Class,Reason,Stack}]),
                         logger:error("The emqx data import failed: ~0p", [{Class,Reason,Stack}]),
                         {error, import_failed}
                         {error, import_failed}

+ 2 - 4
apps/emqx_management/src/emqx_mgmt_cli.erl

@@ -567,7 +567,6 @@ data(["export"]) ->
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
-    Schemas = emqx_mgmt:export_schemas(),
     Seconds = erlang:system_time(second),
     Seconds = erlang:system_time(second),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
@@ -583,8 +582,8 @@ data(["export"]) ->
             {auth_clientid, AuthClientID},
             {auth_clientid, AuthClientID},
             {auth_username, AuthUsername},
             {auth_username, AuthUsername},
             {auth_mnesia, AuthMnesia},
             {auth_mnesia, AuthMnesia},
-            {acl_mnesia, AclMnesia},
-            {schemas, Schemas}],
+            {acl_mnesia, AclMnesia}
+            ],
     ok = filelib:ensure_dir(NFilename),
     ok = filelib:ensure_dir(NFilename),
     case file:write_file(NFilename, emqx_json:encode(Data)) of
     case file:write_file(NFilename, emqx_json:encode(Data)) of
         ok ->
         ok ->
@@ -610,7 +609,6 @@ data(["import", Filename]) ->
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
                         emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, [])),
                         emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, [])),
                         emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, [])),
                         emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, [])),
-                        emqx_mgmt:import_schemas(maps:get(<<"schemas">>, Data, [])),
                         emqx_ctl:print("The emqx data has been imported successfully.~n")
                         emqx_ctl:print("The emqx data has been imported successfully.~n")
                     catch Class:Reason:Stack ->
                     catch Class:Reason:Stack ->
                         emqx_ctl:print("The emqx data import failed due: ~0p~n", [{Class,Reason,Stack}])
                         emqx_ctl:print("The emqx data import failed due: ~0p~n", [{Class,Reason,Stack}])