diff --git a/apps/emqx/test/emqx_common_test_helpers.erl b/apps/emqx/test/emqx_common_test_helpers.erl index d8e0690f2..c22944209 100644 --- a/apps/emqx/test/emqx_common_test_helpers.erl +++ b/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(), diff --git a/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_consumer_SUITE.erl b/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_consumer_SUITE.erl index 4f98f33cf..c17d21635 100644 --- a/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_consumer_SUITE.erl +++ b/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]), diff --git a/apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_impl_producer_SUITE.erl b/apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_impl_producer_SUITE.erl index be38f6625..76d9f94e1 100644 --- a/apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_impl_producer_SUITE.erl +++ b/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]), diff --git a/apps/emqx_conf/src/emqx_conf_schema.erl b/apps/emqx_conf/src/emqx_conf_schema.erl index 97efa67cc..6adb456ca 100644 --- a/apps/emqx_conf/src/emqx_conf_schema.erl +++ b/apps/emqx_conf/src/emqx_conf_schema.erl @@ -560,7 +560,7 @@ fields("node") -> emqx_schema:comma_separated_atoms(), #{ mapping => "emqx_machine.applications", - default => [], + default => <<"">>, 'readOnly' => true, importance => ?IMPORTANCE_HIDDEN, desc => ?DESC(node_applications) diff --git a/lib-ee/emqx_ee_conf/.gitignore b/apps/emqx_enterprise/.gitignore similarity index 100% rename from lib-ee/emqx_ee_conf/.gitignore rename to apps/emqx_enterprise/.gitignore diff --git a/apps/emqx_enterprise/BSL.txt b/apps/emqx_enterprise/BSL.txt new file mode 100644 index 000000000..0acc0e696 --- /dev/null +++ b/apps/emqx_enterprise/BSL.txt @@ -0,0 +1,94 @@ +Business Source License 1.1 + +Licensor: Hangzhou EMQ Technologies Co., Ltd. +Licensed Work: EMQX Enterprise Edition + The Licensed Work is (c) 2023 + Hangzhou EMQ Technologies Co., Ltd. +Additional Use Grant: Students and educators are granted right to copy, + modify, and create derivative work for research + or education. +Change Date: 2027-02-01 +Change License: Apache License, Version 2.0 + +For information about alternative licensing arrangements for the Software, +please contact Licensor: https://www.emqx.com/en/contact + +Notice + +The Business Source License (this document, or the “License”) is not an Open +Source license. However, the Licensed Work will eventually be made available +under an Open Source License, as stated in this License. + +License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. +“Business Source License” is a trademark of MariaDB Corporation Ab. + +----------------------------------------------------------------------------- + +Business Source License 1.1 + +Terms + +The Licensor hereby grants you the right to copy, modify, create derivative +works, redistribute, and make non-production use of the Licensed Work. The +Licensor may make an Additional Use Grant, above, permitting limited +production use. + +Effective on the Change Date, or the fourth anniversary of the first publicly +available distribution of a specific version of the Licensed Work under this +License, whichever comes first, the Licensor hereby grants you rights under +the terms of the Change License, and the rights granted in the paragraph +above terminate. + +If your use of the Licensed Work does not comply with the requirements +currently in effect as described in this License, you must purchase a +commercial license from the Licensor, its affiliated entities, or authorized +resellers, or you must refrain from using the Licensed Work. + +All copies of the original and modified Licensed Work, and derivative works +of the Licensed Work, are subject to this License. This License applies +separately for each version of the Licensed Work and the Change Date may vary +for each version of the Licensed Work released by Licensor. + +You must conspicuously display this License on each original or modified copy +of the Licensed Work. If you receive the Licensed Work in original or +modified form from a third party, the terms and conditions set forth in this +License apply to your use of that work. + +Any use of the Licensed Work in violation of this License will automatically +terminate your rights under this License for the current and all other +versions of the Licensed Work. + +This License does not grant you any right in any trademark or logo of +Licensor or its affiliates (provided that you may use a trademark or logo of +Licensor as expressly required by this License). + +TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +TITLE. + +MariaDB hereby grants you permission to use this License’s text to license +your works, and to refer to it using the trademark “Business Source License”, +as long as you comply with the Covenants of Licensor below. + +Covenants of Licensor + +In consideration of the right to use this License’s text and the “Business +Source License” name and trademark, Licensor covenants to MariaDB, and to all +other recipients of the licensed work to be provided by Licensor: + +1. To specify as the Change License the GPL Version 2.0 or any later version, + or a license that is compatible with GPL Version 2.0 or a later version, + where “compatible” means that software provided under the Change License can + be included in a program with software provided under GPL Version 2.0 or a + later version. Licensor may specify additional Change Licenses without + limitation. + +2. To either: (a) specify an additional grant of rights to use that does not + impose any additional restriction on the right granted in this License, as + the Additional Use Grant; or (b) insert the text “None”. + +3. To specify a Change Date. + +4. Not to modify this License in any other way. diff --git a/apps/emqx_enterprise/README.md b/apps/emqx_enterprise/README.md new file mode 100644 index 000000000..06f249581 --- /dev/null +++ b/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. + diff --git a/lib-ee/emqx_ee_conf/etc/emqx-enterprise.conf b/apps/emqx_enterprise/etc/emqx-enterprise.conf similarity index 100% rename from lib-ee/emqx_ee_conf/etc/emqx-enterprise.conf rename to apps/emqx_enterprise/etc/emqx-enterprise.conf diff --git a/lib-ee/emqx_ee_conf/rebar.config b/apps/emqx_enterprise/rebar.config similarity index 100% rename from lib-ee/emqx_ee_conf/rebar.config rename to apps/emqx_enterprise/rebar.config diff --git a/lib-ee/emqx_ee_conf/src/emqx_ee_conf.app.src b/apps/emqx_enterprise/src/emqx_enterprise.app.src similarity index 53% rename from lib-ee/emqx_ee_conf/src/emqx_ee_conf.app.src rename to apps/emqx_enterprise/src/emqx_enterprise.app.src index 3df18ce7a..84c3ffc02 100644 --- a/lib-ee/emqx_ee_conf/src/emqx_ee_conf.app.src +++ b/apps/emqx_enterprise/src/emqx_enterprise.app.src @@ -1,6 +1,6 @@ -{application, emqx_ee_conf, [ - {description, "EMQX Enterprise Edition configuration schema"}, - {vsn, "0.1.2"}, +{application, emqx_enterprise, [ + {description, "EMQX Enterprise Edition"}, + {vsn, "0.1.0"}, {registered, []}, {applications, [ kernel, diff --git a/apps/emqx_enterprise/src/emqx_enterprise_schema.erl b/apps/emqx_enterprise/src/emqx_enterprise_schema.erl new file mode 100644 index 000000000..971d1a56f --- /dev/null +++ b/apps/emqx_enterprise/src/emqx_enterprise_schema.erl @@ -0,0 +1,65 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved. +%%-------------------------------------------------------------------- + +-module(emqx_enterprise_schema). + +-behaviour(hocon_schema). + +-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]). + +namespace() -> + emqx_conf_schema:namespace(). + +roots() -> + redefine_roots( + lists:foldl( + fun(Module, Roots) -> + Roots ++ apply(Module, roots, []) + end, + emqx_conf_schema:roots(), + ?EE_SCHEMA_MODULES + ) + ). + +fields("node") -> + redefine_node(emqx_conf_schema:fields("node")); +fields(Name) -> + emqx_conf_schema:fields(Name). + +translations() -> + emqx_conf_schema:translations(). + +translation(Name) -> + emqx_conf_schema:translation(Name). + +validations() -> + emqx_conf_schema:validations(). + +redefine_node(Fields) -> + Overrides = [{"applications", #{default => <<"emqx_license">>}}], + override(Fields, Overrides). + +redefine_roots(Roots) -> + Overrides = [{"node", #{type => hoconsc:ref(?MODULE, "node")}}], + override(Roots, Overrides). + +override(Fields, []) -> + Fields; +override(Fields, [{Name, Override} | More]) -> + Schema = find_schema(Name, Fields), + NewSchema = hocon_schema:override(Schema, Override), + NewFields = replace_schema(Name, NewSchema, Fields), + override(NewFields, More). + +find_schema(Name, Fields) -> + {Name, Schema} = lists:keyfind(Name, 1, Fields), + Schema. + +replace_schema(Name, Schema, Fields) -> + lists:keyreplace(Name, 1, Fields, {Name, Schema}). + +desc(Name) -> + emqx_conf_schema:desc(Name). diff --git a/apps/emqx_enterprise/test/emqx_enterprise_schema_SUITE.erl b/apps/emqx_enterprise/test/emqx_enterprise_schema_SUITE.erl new file mode 100644 index 000000000..e7f4c0075 --- /dev/null +++ b/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) + ). diff --git a/lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_tests.erl b/apps/emqx_enterprise/test/emqx_enterprise_schema_tests.erl similarity index 85% rename from lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_tests.erl rename to apps/emqx_enterprise/test/emqx_enterprise_schema_tests.erl index 5e1d4e551..a78bbcb2e 100644 --- a/lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_tests.erl +++ b/apps/emqx_enterprise/test/emqx_enterprise_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 }. diff --git a/build b/build index 0846d6057..5e396fdd2 100755 --- a/build +++ b/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' diff --git a/dev b/dev index 3ac8cb5c7..425da993a 100755 --- a/dev +++ b/dev @@ -131,10 +131,10 @@ export PROFILE case "${PROFILE}" in emqx) - SCHEMA_MOD='emqx_conf_schema' + export SCHEMA_MOD='emqx_conf_schema' ;; emqx-enterprise) - SCHEMA_MOD='emqx_ee_conf_schema' + export SCHEMA_MOD='emqx_enterprise_schema' ;; esac @@ -329,11 +329,10 @@ boot() { copy_other_conf_files APPS="$(apps_to_load)" - BOOT_SEQUENCE=" Apps=[${APPS}], ok=lists:foreach(fun application:load/1, Apps), - io:format(user, \"~nLoaded ~p apps~n\", [length(Apps)]), + io:format(user, \"~nLoaded: ~p~n\", [Apps]), {ok, _} = application:ensure_all_started(emqx_machine). " diff --git a/lib-ee/emqx_ee_conf/README.md b/lib-ee/emqx_ee_conf/README.md deleted file mode 100644 index 701d285cc..000000000 --- a/lib-ee/emqx_ee_conf/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# emqx_ee_conf - -EMQX Enterprise configuration schema diff --git a/lib-ee/emqx_ee_conf/src/emqx_ee_conf_schema.erl b/lib-ee/emqx_ee_conf/src/emqx_ee_conf_schema.erl deleted file mode 100644 index c1b1a002c..000000000 --- a/lib-ee/emqx_ee_conf/src/emqx_ee_conf_schema.erl +++ /dev/null @@ -1,35 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved. -%%-------------------------------------------------------------------- - --module(emqx_ee_conf_schema). - --behaviour(hocon_schema). - --export([namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0]). - --define(EE_SCHEMA_MODULES, [emqx_license_schema, emqx_ee_schema_registry_schema]). - -namespace() -> - emqx_conf_schema:namespace(). - -roots() -> - lists:foldl( - fun(Module, Roots) -> - Roots ++ apply(Module, roots, []) - end, - emqx_conf_schema:roots(), - ?EE_SCHEMA_MODULES - ). - -fields(Name) -> - emqx_conf_schema:fields(Name). - -translations() -> - emqx_conf_schema:translations(). - -translation(Name) -> - emqx_conf_schema:translation(Name). - -validations() -> - emqx_conf_schema:validations(). diff --git a/lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_SUITE.erl b/lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_SUITE.erl deleted file mode 100644 index 941c3e4d1..000000000 --- a/lib-ee/emqx_ee_conf/test/emqx_ee_conf_schema_SUITE.erl +++ /dev/null @@ -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) - ). diff --git a/lib-ee/emqx_ee_schema_registry/test/emqx_ee_schema_registry_SUITE.erl b/lib-ee/emqx_ee_schema_registry/test/emqx_ee_schema_registry_SUITE.erl index 7ad01fa06..d17c159c3 100644 --- a/lib-ee/emqx_ee_schema_registry/test/emqx_ee_schema_registry_SUITE.erl +++ b/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. diff --git a/lib-ee/emqx_license/test/emqx_license_SUITE.erl b/lib-ee/emqx_license/test/emqx_license_SUITE.erl index 4a0f6d91b..69adabe76 100644 --- a/lib-ee/emqx_license/test/emqx_license_SUITE.erl +++ b/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, diff --git a/mix.exs b/mix.exs index 717172041..c7fc1e3c0 100644 --- a/mix.exs +++ b/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 diff --git a/rebar.config.erl b/rebar.config.erl index d556b41aa..a740ab183 100644 --- a/rebar.config.erl +++ b/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,