refactor: rename lib-ee/emqx_ee_conf to apps/emqx_enterprise
This commit is contained in:
parent
3482c2c849
commit
40e8d5d039
|
@ -860,7 +860,7 @@ setup_node(Node, Opts) when is_map(Opts) ->
|
||||||
begin
|
begin
|
||||||
%% to avoid sharing data between executions and/or
|
%% to avoid sharing data between executions and/or
|
||||||
%% nodes. these variables might not be in the
|
%% nodes. these variables might not be in the
|
||||||
%% config file (e.g.: emqx_ee_conf_schema).
|
%% config file (e.g.: emqx_enterprise_schema).
|
||||||
NodeDataDir = filename:join([
|
NodeDataDir = filename:join([
|
||||||
PrivDataDir,
|
PrivDataDir,
|
||||||
node(),
|
node(),
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ cluster(Config) ->
|
||||||
{priv_data_dir, PrivDataDir},
|
{priv_data_dir, PrivDataDir},
|
||||||
{load_schema, true},
|
{load_schema, true},
|
||||||
{start_autocluster, true},
|
{start_autocluster, true},
|
||||||
{schema_mod, emqx_ee_conf_schema},
|
{schema_mod, emqx_enterprise_schema},
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx) ->
|
(emqx) ->
|
||||||
application:set_env(emqx, boot_modules, [broker, router]),
|
application:set_env(emqx, boot_modules, [broker, router]),
|
||||||
|
|
|
@ -496,7 +496,7 @@ cluster(Config) ->
|
||||||
{priv_data_dir, PrivDataDir},
|
{priv_data_dir, PrivDataDir},
|
||||||
{load_schema, true},
|
{load_schema, true},
|
||||||
{start_autocluster, true},
|
{start_autocluster, true},
|
||||||
{schema_mod, emqx_ee_conf_schema},
|
{schema_mod, emqx_enterprise_schema},
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx) ->
|
(emqx) ->
|
||||||
application:set_env(emqx, boot_modules, [broker, router]),
|
application:set_env(emqx, boot_modules, [broker, router]),
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_ee_conf, [
|
{application, emqx_enterprise, [
|
||||||
{description, "EMQX Enterprise Edition configuration schema"},
|
{description, "EMQX Enterprise Edition"},
|
||||||
{vsn, "0.1.3"},
|
{vsn, "0.1.0"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
|
@ -2,11 +2,11 @@
|
||||||
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-module(emqx_ee_conf_schema).
|
-module(emqx_enterprise_schema).
|
||||||
|
|
||||||
-behaviour(hocon_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]).
|
-define(EE_SCHEMA_MODULES, [emqx_license_schema, emqx_ee_schema_registry_schema]).
|
||||||
|
|
||||||
|
@ -48,10 +48,11 @@ redefine_roots(Roots) ->
|
||||||
|
|
||||||
override(Fields, []) ->
|
override(Fields, []) ->
|
||||||
Fields;
|
Fields;
|
||||||
override(Fields, [{Name, Override}]) ->
|
override(Fields, [{Name, Override} | More]) ->
|
||||||
Schema = find_schema(Name, Fields),
|
Schema = find_schema(Name, Fields),
|
||||||
NewSchema = hocon_schema:override(Schema, Override),
|
NewSchema = hocon_schema:override(Schema, Override),
|
||||||
replace_schema(Name, NewSchema, Fields).
|
NewFields = replace_schema(Name, NewSchema, Fields),
|
||||||
|
override(NewFields, More).
|
||||||
|
|
||||||
find_schema(Name, Fields) ->
|
find_schema(Name, Fields) ->
|
||||||
{Name, Schema} = lists:keyfind(Name, 1, Fields),
|
{Name, Schema} = lists:keyfind(Name, 1, Fields),
|
||||||
|
@ -59,3 +60,6 @@ find_schema(Name, Fields) ->
|
||||||
|
|
||||||
replace_schema(Name, Schema, Fields) ->
|
replace_schema(Name, Schema, Fields) ->
|
||||||
lists:keyreplace(Name, 1, Fields, {Name, Schema}).
|
lists:keyreplace(Name, 1, Fields, {Name, Schema}).
|
||||||
|
|
||||||
|
desc(Name) ->
|
||||||
|
emqx_conf_schema:desc(Name).
|
|
@ -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,7 +2,7 @@
|
||||||
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% 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").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ doc_gen_test() ->
|
||||||
"priv",
|
"priv",
|
||||||
"i18n.conf"
|
"i18n.conf"
|
||||||
]),
|
]),
|
||||||
_ = emqx_conf:dump_schema(Dir, emqx_ee_conf_schema, I18nFile),
|
_ = emqx_conf:dump_schema(Dir, emqx_enterprise_schema, I18nFile),
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
}.
|
}.
|
2
build
2
build
|
@ -106,7 +106,7 @@ make_docs() {
|
||||||
fi
|
fi
|
||||||
case "$(is_enterprise "$PROFILE")" in
|
case "$(is_enterprise "$PROFILE")" in
|
||||||
'yes')
|
'yes')
|
||||||
SCHEMA_MODULE='emqx_ee_conf_schema'
|
SCHEMA_MODULE='emqx_enterprise_schema'
|
||||||
;;
|
;;
|
||||||
'no')
|
'no')
|
||||||
SCHEMA_MODULE='emqx_conf_schema'
|
SCHEMA_MODULE='emqx_conf_schema'
|
||||||
|
|
2
dev
2
dev
|
@ -134,7 +134,7 @@ case "${PROFILE}" in
|
||||||
export SCHEMA_MOD='emqx_conf_schema'
|
export SCHEMA_MOD='emqx_conf_schema'
|
||||||
;;
|
;;
|
||||||
emqx-enterprise)
|
emqx-enterprise)
|
||||||
export SCHEMA_MOD='emqx_ee_conf_schema'
|
export SCHEMA_MOD='emqx_enterprise_schema'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# emqx_ee_conf
|
|
||||||
|
|
||||||
EMQX Enterprise configuration schema
|
|
|
@ -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)
|
|
||||||
).
|
|
|
@ -345,7 +345,7 @@ cluster(Config) ->
|
||||||
{priv_data_dir, PrivDataDir},
|
{priv_data_dir, PrivDataDir},
|
||||||
{load_schema, true},
|
{load_schema, true},
|
||||||
{start_autocluster, 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
|
%% need to restart schema registry app in the tests so
|
||||||
%% that it re-registers the config handler that is lost
|
%% that it re-registers the config handler that is lost
|
||||||
%% when emqx_conf restarts during join.
|
%% when emqx_conf restarts during join.
|
||||||
|
|
|
@ -73,10 +73,10 @@ setup_test(TestCase, Config) when
|
||||||
[
|
[
|
||||||
{apps, [emqx_conf, emqx_license]},
|
{apps, [emqx_conf, emqx_license]},
|
||||||
{load_schema, false},
|
{load_schema, false},
|
||||||
{schema_mod, emqx_ee_conf_schema},
|
{schema_mod, emqx_enterprise_schema},
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx) ->
|
(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),
|
%% emqx_config:save_schema_mod_and_names(emqx_license_schema),
|
||||||
application:set_env(emqx, boot_modules, []),
|
application:set_env(emqx, boot_modules, []),
|
||||||
application:set_env(
|
application:set_env(
|
||||||
|
@ -90,7 +90,7 @@ setup_test(TestCase, Config) when
|
||||||
),
|
),
|
||||||
ok;
|
ok;
|
||||||
(emqx_conf) ->
|
(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),
|
%% emqx_config:save_schema_mod_and_names(emqx_license_schema),
|
||||||
application:set_env(
|
application:set_env(
|
||||||
emqx,
|
emqx,
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -384,7 +384,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
if(edition_type == :enterprise,
|
if(edition_type == :enterprise,
|
||||||
do: [
|
do: [
|
||||||
emqx_license: :permanent,
|
emqx_license: :permanent,
|
||||||
emqx_ee_conf: :load,
|
emqx_enterprise: :load,
|
||||||
emqx_ee_connector: :permanent,
|
emqx_ee_connector: :permanent,
|
||||||
emqx_ee_bridge: :permanent,
|
emqx_ee_bridge: :permanent,
|
||||||
emqx_bridge_kafka: :permanent,
|
emqx_bridge_kafka: :permanent,
|
||||||
|
@ -785,7 +785,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
end
|
end
|
||||||
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 emqx_schema_mod(:community), do: :emqx_conf_schema
|
||||||
|
|
||||||
defp bcrypt_dep() do
|
defp bcrypt_dep() do
|
||||||
|
|
|
@ -346,7 +346,7 @@ overlay_vars_edition(ce) ->
|
||||||
];
|
];
|
||||||
overlay_vars_edition(ee) ->
|
overlay_vars_edition(ee) ->
|
||||||
[
|
[
|
||||||
{emqx_schema_mod, emqx_ee_conf_schema},
|
{emqx_schema_mod, emqx_enterprise_schema},
|
||||||
{is_enterprise, "yes"}
|
{is_enterprise, "yes"}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ is_app(Name) ->
|
||||||
relx_apps_per_edition(ee) ->
|
relx_apps_per_edition(ee) ->
|
||||||
[
|
[
|
||||||
emqx_license,
|
emqx_license,
|
||||||
{emqx_ee_conf, load},
|
{emqx_enterprise, load},
|
||||||
emqx_ee_connector,
|
emqx_ee_connector,
|
||||||
emqx_ee_bridge,
|
emqx_ee_bridge,
|
||||||
emqx_bridge_kafka,
|
emqx_bridge_kafka,
|
||||||
|
|
Loading…
Reference in New Issue