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

refactor: rename lib-ee/emqx_ee_conf to apps/emqx_enterprise

Zaiming (Stone) Shi 2 лет назад
Родитель
Сommit
40e8d5d039

+ 2 - 2
apps/emqx/test/emqx_common_test_helpers.erl

@@ -859,8 +859,8 @@ setup_node(Node, Opts) when is_map(Opts) ->
             LoadSchema andalso
                 begin
                     %% to avoid sharing data between executions and/or
-                    %% nodes.  these variables might notbe in the
-                    %% config file (e.g.: emqx_ee_conf_schema).
+                    %% nodes.  these variables might not be in the
+                    %% config file (e.g.: emqx_enterprise_schema).
                     NodeDataDir = filename:join([
                         PrivDataDir,
                         node(),

+ 1 - 1
apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_consumer_SUITE.erl

@@ -1076,7 +1076,7 @@ cluster(Config) ->
             {priv_data_dir, PrivDataDir},
             {load_schema, true},
             {start_autocluster, true},
-            {schema_mod, emqx_ee_conf_schema},
+            {schema_mod, emqx_enterprise_schema},
             {env_handler, fun
                 (emqx) ->
                     application:set_env(emqx, boot_modules, [broker, router]),

+ 1 - 1
apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_impl_producer_SUITE.erl

@@ -496,7 +496,7 @@ cluster(Config) ->
             {priv_data_dir, PrivDataDir},
             {load_schema, true},
             {start_autocluster, true},
-            {schema_mod, emqx_ee_conf_schema},
+            {schema_mod, emqx_enterprise_schema},
             {env_handler, fun
                 (emqx) ->
                     application:set_env(emqx, boot_modules, [broker, router]),

lib-ee/emqx_ee_conf/.gitignore → apps/emqx_enterprise/.gitignore


+ 6 - 0
apps/emqx_enterprise/README.md

@@ -0,0 +1,6 @@
+# EMQX Enterprise Application
+
+This application so fart only holds EMQX config schema for enterprise edition.
+In the future this application will collect more responsibilities in managing
+enterprise edition specific features.
+

lib-ee/emqx_ee_conf/etc/emqx-enterprise.conf → apps/emqx_enterprise/etc/emqx-enterprise.conf


lib-ee/emqx_ee_conf/rebar.config → apps/emqx_enterprise/rebar.config


+ 3 - 3
lib-ee/emqx_ee_conf/src/emqx_ee_conf.app.src

@@ -1,6 +1,6 @@
-{application, emqx_ee_conf, [
-    {description, "EMQX Enterprise Edition configuration schema"},
-    {vsn, "0.1.3"},
+{application, emqx_enterprise, [
+    {description, "EMQX Enterprise Edition"},
+    {vsn, "0.1.0"},
     {registered, []},
     {applications, [
         kernel,

+ 8 - 4
lib-ee/emqx_ee_conf/src/emqx_ee_conf_schema.erl

@@ -2,11 +2,11 @@
 %% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
 %%--------------------------------------------------------------------
 
--module(emqx_ee_conf_schema).
+-module(emqx_enterprise_schema).
 
 -behaviour(hocon_schema).
 
--export([namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0]).
+-export([namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0, desc/1]).
 
 -define(EE_SCHEMA_MODULES, [emqx_license_schema, emqx_ee_schema_registry_schema]).
 
@@ -48,10 +48,11 @@ redefine_roots(Roots) ->
 
 override(Fields, []) ->
     Fields;
-override(Fields, [{Name, Override}]) ->
+override(Fields, [{Name, Override} | More]) ->
     Schema = find_schema(Name, Fields),
     NewSchema = hocon_schema:override(Schema, Override),
-    replace_schema(Name, NewSchema, Fields).
+    NewFields = replace_schema(Name, NewSchema, Fields),
+    override(NewFields, More).
 
 find_schema(Name, Fields) ->
     {Name, Schema} = lists:keyfind(Name, 1, Fields),
@@ -59,3 +60,6 @@ find_schema(Name, Fields) ->
 
 replace_schema(Name, Schema, Fields) ->
     lists:keyreplace(Name, 1, Fields, {Name, Schema}).
+
+desc(Name) ->
+    emqx_conf_schema:desc(Name).

+ 52 - 0
apps/emqx_enterprise/test/emqx_enterprise_schema_SUITE.erl

@@ -0,0 +1,52 @@
+%%--------------------------------------------------------------------
+%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
+%%--------------------------------------------------------------------
+
+-module(emqx_enterprise_schema_SUITE).
+
+-compile(nowarn_export_all).
+-compile(export_all).
+
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("common_test/include/ct.hrl").
+
+all() ->
+    emqx_common_test_helpers:all(?MODULE).
+
+%%------------------------------------------------------------------------------
+%% Tests
+%%------------------------------------------------------------------------------
+
+t_namespace(_Config) ->
+    ?assertEqual(
+        emqx_conf_schema:namespace(),
+        emqx_enterprise_schema:namespace()
+    ).
+
+t_roots(_Config) ->
+    EnterpriseRoots = emqx_enterprise_schema:roots(),
+    ?assertMatch({license, _}, lists:keyfind(license, 1, EnterpriseRoots)).
+
+t_fields(_Config) ->
+    CeFields = emqx_conf_schema:fields("node"),
+    EeFields = emqx_enterprise_schema:fields("node"),
+    ?assertEqual(length(CeFields), length(EeFields)),
+    lists:foreach(
+        fun({{CeName, CeSchema}, {EeName, EeSchema}}) ->
+            ?assertEqual(CeName, EeName),
+            case CeName of
+                "applications" ->
+                    ok;
+                _ ->
+                    ?assertEqual({CeName, CeSchema}, {EeName, EeSchema})
+            end
+        end,
+        lists:zip(CeFields, EeFields)
+    ).
+
+t_translations(_Config) ->
+    [Root | _] = emqx_enterprise_schema:translations(),
+    ?assertEqual(
+        emqx_conf_schema:translation(Root),
+        emqx_enterprise_schema:translation(Root)
+    ).

+ 2 - 2
lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_tests.erl

@@ -2,7 +2,7 @@
 %% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
 %%--------------------------------------------------------------------
 
--module(emqx_ee_conf_schema_tests).
+-module(emqx_enterprise_schema_tests).
 
 -include_lib("eunit/include/eunit.hrl").
 
@@ -22,7 +22,7 @@ doc_gen_test() ->
                 "priv",
                 "i18n.conf"
             ]),
-            _ = emqx_conf:dump_schema(Dir, emqx_ee_conf_schema, I18nFile),
+            _ = emqx_conf:dump_schema(Dir, emqx_enterprise_schema, I18nFile),
             ok
         end
     }.

+ 1 - 1
build

@@ -106,7 +106,7 @@ make_docs() {
     fi
     case "$(is_enterprise "$PROFILE")" in
         'yes')
-            SCHEMA_MODULE='emqx_ee_conf_schema'
+            SCHEMA_MODULE='emqx_enterprise_schema'
             ;;
         'no')
             SCHEMA_MODULE='emqx_conf_schema'

+ 1 - 1
dev

@@ -134,7 +134,7 @@ case "${PROFILE}" in
         export SCHEMA_MOD='emqx_conf_schema'
         ;;
     emqx-enterprise)
-        export SCHEMA_MOD='emqx_ee_conf_schema'
+        export SCHEMA_MOD='emqx_enterprise_schema'
         ;;
 esac
 

+ 0 - 3
lib-ee/emqx_ee_conf/README.md

@@ -1,3 +0,0 @@
-# emqx_ee_conf
-
-EMQX Enterprise configuration schema

+ 0 - 53
lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_SUITE.erl

@@ -1,53 +0,0 @@
-%%--------------------------------------------------------------------
-%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
-%%--------------------------------------------------------------------
-
--module(emqx_ee_conf_schema_SUITE).
-
--compile(nowarn_export_all).
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
--include_lib("common_test/include/ct.hrl").
-
-all() ->
-    emqx_common_test_helpers:all(?MODULE).
-
-%%------------------------------------------------------------------------------
-%% Tests
-%%------------------------------------------------------------------------------
-
-t_namespace(_Config) ->
-    ?assertEqual(
-        emqx_conf_schema:namespace(),
-        emqx_ee_conf_schema:namespace()
-    ).
-
-t_roots(_Config) ->
-    BaseRoots = emqx_conf_schema:roots(),
-    EnterpriseRoots = emqx_ee_conf_schema:roots(),
-
-    ?assertEqual([], BaseRoots -- EnterpriseRoots),
-
-    ?assert(
-        lists:any(
-            fun
-                ({license, _}) -> true;
-                (_) -> false
-            end,
-            EnterpriseRoots
-        )
-    ).
-
-t_fields(_Config) ->
-    ?assertEqual(
-        emqx_conf_schema:fields("node"),
-        emqx_ee_conf_schema:fields("node")
-    ).
-
-t_translations(_Config) ->
-    [Root | _] = emqx_ee_conf_schema:translations(),
-    ?assertEqual(
-        emqx_conf_schema:translation(Root),
-        emqx_ee_conf_schema:translation(Root)
-    ).

+ 1 - 1
lib-ee/emqx_ee_schema_registry/test/emqx_ee_schema_registry_SUITE.erl

@@ -345,7 +345,7 @@ cluster(Config) ->
             {priv_data_dir, PrivDataDir},
             {load_schema, true},
             {start_autocluster, true},
-            {schema_mod, emqx_ee_conf_schema},
+            {schema_mod, emqx_enterprise_schema},
             %% need to restart schema registry app in the tests so
             %% that it re-registers the config handler that is lost
             %% when emqx_conf restarts during join.

+ 3 - 3
lib-ee/emqx_license/test/emqx_license_SUITE.erl

@@ -73,10 +73,10 @@ setup_test(TestCase, Config) when
         [
             {apps, [emqx_conf, emqx_license]},
             {load_schema, false},
-            {schema_mod, emqx_ee_conf_schema},
+            {schema_mod, emqx_enterprise_schema},
             {env_handler, fun
                 (emqx) ->
-                    emqx_config:save_schema_mod_and_names(emqx_ee_conf_schema),
+                    emqx_config:save_schema_mod_and_names(emqx_enterprise_schema),
                     %% emqx_config:save_schema_mod_and_names(emqx_license_schema),
                     application:set_env(emqx, boot_modules, []),
                     application:set_env(
@@ -90,7 +90,7 @@ setup_test(TestCase, Config) when
                     ),
                     ok;
                 (emqx_conf) ->
-                    emqx_config:save_schema_mod_and_names(emqx_ee_conf_schema),
+                    emqx_config:save_schema_mod_and_names(emqx_enterprise_schema),
                     %% emqx_config:save_schema_mod_and_names(emqx_license_schema),
                     application:set_env(
                         emqx,

+ 2 - 2
mix.exs

@@ -384,7 +384,7 @@ defmodule EMQXUmbrella.MixProject do
       if(edition_type == :enterprise,
         do: [
           emqx_license: :permanent,
-          emqx_ee_conf: :load,
+          emqx_enterprise: :load,
           emqx_ee_connector: :permanent,
           emqx_ee_bridge: :permanent,
           emqx_bridge_kafka: :permanent,
@@ -785,7 +785,7 @@ defmodule EMQXUmbrella.MixProject do
     end
   end
 
-  defp emqx_schema_mod(:enterprise), do: :emqx_ee_conf_schema
+  defp emqx_schema_mod(:enterprise), do: :emqx_enterprise_schema
   defp emqx_schema_mod(:community), do: :emqx_conf_schema
 
   defp bcrypt_dep() do

+ 2 - 2
rebar.config.erl

@@ -346,7 +346,7 @@ overlay_vars_edition(ce) ->
     ];
 overlay_vars_edition(ee) ->
     [
-        {emqx_schema_mod, emqx_ee_conf_schema},
+        {emqx_schema_mod, emqx_enterprise_schema},
         {is_enterprise, "yes"}
     ].
 
@@ -453,7 +453,7 @@ is_app(Name) ->
 relx_apps_per_edition(ee) ->
     [
         emqx_license,
-        {emqx_ee_conf, load},
+        {emqx_enterprise, load},
         emqx_ee_connector,
         emqx_ee_bridge,
         emqx_bridge_kafka,