Merge pull request #13294 from zmstone/0618-per-release-edition-code-injection
0618 per release edition code injection
This commit is contained in:
commit
95d387a790
|
@ -24,11 +24,18 @@
|
|||
version/0,
|
||||
version_with_prefix/0,
|
||||
vsn_compare/1,
|
||||
vsn_compare/2
|
||||
vsn_compare/2,
|
||||
on_load/0
|
||||
]).
|
||||
|
||||
-on_load(on_load/0).
|
||||
|
||||
-include("emqx_release.hrl").
|
||||
|
||||
-ifndef(EMQX_RELEASE_EDITION).
|
||||
-define(EMQX_RELEASE_EDITION, ce).
|
||||
-endif.
|
||||
|
||||
-define(EMQX_DESCS, #{
|
||||
ee => "EMQX Enterprise",
|
||||
ce => "EMQX"
|
||||
|
@ -49,6 +56,11 @@
|
|||
ce => "v"
|
||||
}).
|
||||
|
||||
%% @hidden Initialize edition. Almost static. use persistent_term to trick compiler.
|
||||
-spec on_load() -> ok.
|
||||
on_load() ->
|
||||
persistent_term:put('EMQX_RELEASE_EDITION', ?EMQX_RELEASE_EDITION).
|
||||
|
||||
%% @doc Return EMQX description.
|
||||
description() ->
|
||||
maps:get(edition(), ?EMQX_DESCS).
|
||||
|
@ -57,11 +69,8 @@ description() ->
|
|||
%% Read info from persistent_term at runtime.
|
||||
%% Or meck this function to run tests for another edition.
|
||||
-spec edition() -> ce | ee.
|
||||
-ifdef(EMQX_RELEASE_EDITION).
|
||||
edition() -> ?EMQX_RELEASE_EDITION.
|
||||
-else.
|
||||
edition() -> ce.
|
||||
-endif.
|
||||
edition() ->
|
||||
persistent_term:get('EMQX_RELEASE_EDITION').
|
||||
|
||||
%% @doc Return EMQX version prefix string.
|
||||
edition_vsn_prefix() ->
|
||||
|
|
|
@ -191,8 +191,6 @@
|
|||
-define(DEFAULT_MULTIPLIER, 1.5).
|
||||
-define(DEFAULT_BACKOFF, 0.75).
|
||||
|
||||
-define(INJECTING_CONFIGS, [?AUTH_EXT_SCHEMA_MODS]).
|
||||
|
||||
namespace() -> emqx.
|
||||
|
||||
tags() ->
|
||||
|
|
|
@ -37,47 +37,4 @@
|
|||
|
||||
-define(READONLY_KEYS, [cluster, rpc, node]).
|
||||
|
||||
-define(CE_AUTHZ_SOURCE_SCHEMA_MODS, [
|
||||
emqx_authz_file_schema,
|
||||
emqx_authz_mnesia_schema,
|
||||
emqx_authz_http_schema,
|
||||
emqx_authz_redis_schema,
|
||||
emqx_authz_mysql_schema,
|
||||
emqx_authz_postgresql_schema,
|
||||
emqx_authz_mongodb_schema,
|
||||
emqx_authz_ldap_schema
|
||||
]).
|
||||
|
||||
-define(EE_AUTHZ_SOURCE_SCHEMA_MODS, []).
|
||||
|
||||
-define(CE_AUTHN_PROVIDER_SCHEMA_MODS, [
|
||||
emqx_authn_mnesia_schema,
|
||||
emqx_authn_mysql_schema,
|
||||
emqx_authn_postgresql_schema,
|
||||
emqx_authn_mongodb_schema,
|
||||
emqx_authn_redis_schema,
|
||||
emqx_authn_http_schema,
|
||||
emqx_authn_jwt_schema,
|
||||
emqx_authn_scram_mnesia_schema,
|
||||
emqx_authn_ldap_schema
|
||||
]).
|
||||
|
||||
-define(EE_AUTHN_PROVIDER_SCHEMA_MODS, [
|
||||
emqx_gcp_device_authn_schema
|
||||
]).
|
||||
|
||||
-if(?EMQX_RELEASE_EDITION == ee).
|
||||
|
||||
-define(AUTHZ_SOURCE_SCHEMA_MODS, ?CE_AUTHZ_SOURCE_SCHEMA_MODS ++ ?EE_AUTHZ_SOURCE_SCHEMA_MODS).
|
||||
-define(AUTHN_PROVIDER_SCHEMA_MODS,
|
||||
(?CE_AUTHN_PROVIDER_SCHEMA_MODS ++ ?EE_AUTHN_PROVIDER_SCHEMA_MODS)
|
||||
).
|
||||
|
||||
-else.
|
||||
|
||||
-define(AUTHZ_SOURCE_SCHEMA_MODS, ?CE_AUTHZ_SOURCE_SCHEMA_MODS).
|
||||
-define(AUTHN_PROVIDER_SCHEMA_MODS, ?CE_AUTHN_PROVIDER_SCHEMA_MODS).
|
||||
|
||||
-endif.
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -71,20 +71,6 @@
|
|||
emqx_mgmt_api_key_schema
|
||||
]).
|
||||
|
||||
-define(AUTH_EXT_SCHEMA_MODS, [emqx_auth_ext_schema]).
|
||||
|
||||
-if(defined(EMQX_RELEASE_EDITION) andalso ?EMQX_RELEASE_EDITION == ee).
|
||||
-define(OTHER_INJECTING_CONFIGS, ?AUTH_EXT_SCHEMA_MODS).
|
||||
-else.
|
||||
-define(OTHER_INJECTING_CONFIGS, []).
|
||||
-endif.
|
||||
|
||||
-define(INJECTING_CONFIGS, [
|
||||
{emqx_authn_schema, ?AUTHN_PROVIDER_SCHEMA_MODS},
|
||||
{emqx_authz_schema, ?AUTHZ_SOURCE_SCHEMA_MODS}
|
||||
| ?OTHER_INJECTING_CONFIGS
|
||||
]).
|
||||
|
||||
%% 1 million default ports counter
|
||||
-define(DEFAULT_MAX_PORTS, 1024 * 1024).
|
||||
|
||||
|
@ -108,7 +94,8 @@ tags() ->
|
|||
[<<"EMQX">>].
|
||||
|
||||
roots() ->
|
||||
ok = emqx_schema_hooks:inject_from_modules(?INJECTING_CONFIGS),
|
||||
Injections = emqx_conf_schema_inject:schemas(),
|
||||
ok = emqx_schema_hooks:inject_from_modules(Injections),
|
||||
emqx_schema_high_prio_roots() ++
|
||||
[
|
||||
{node,
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
%%--------------------------------------------------------------------
|
||||
%% Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||
%%
|
||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||
%% you may not use this file except in compliance with the License.
|
||||
%% You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing, software
|
||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
%% See the License for the specific language governing permissions and
|
||||
%% limitations under the License.
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
-module(emqx_conf_schema_inject).
|
||||
|
||||
-export([schemas/0]).
|
||||
|
||||
schemas() ->
|
||||
schemas(emqx_release:edition()).
|
||||
|
||||
schemas(Edition) ->
|
||||
auth_ext(Edition) ++
|
||||
authn(Edition) ++
|
||||
authz() ++
|
||||
customized().
|
||||
|
||||
auth_ext(ce) ->
|
||||
[];
|
||||
auth_ext(ee) ->
|
||||
[emqx_auth_ext_schema].
|
||||
|
||||
authn(Edition) ->
|
||||
[{emqx_authn_schema, authn_mods(Edition)}].
|
||||
|
||||
authn_mods(ce) ->
|
||||
[
|
||||
emqx_authn_mnesia_schema,
|
||||
emqx_authn_mysql_schema,
|
||||
emqx_authn_postgresql_schema,
|
||||
emqx_authn_mongodb_schema,
|
||||
emqx_authn_redis_schema,
|
||||
emqx_authn_http_schema,
|
||||
emqx_authn_jwt_schema,
|
||||
emqx_authn_scram_mnesia_schema,
|
||||
emqx_authn_ldap_schema
|
||||
];
|
||||
authn_mods(ee) ->
|
||||
authn_mods(ce) ++
|
||||
[emqx_gcp_device_authn_schema].
|
||||
|
||||
authz() ->
|
||||
[{emqx_authz_schema, authz_mods()}].
|
||||
|
||||
authz_mods() ->
|
||||
[
|
||||
emqx_authz_file_schema,
|
||||
emqx_authz_mnesia_schema,
|
||||
emqx_authz_http_schema,
|
||||
emqx_authz_redis_schema,
|
||||
emqx_authz_mysql_schema,
|
||||
emqx_authz_postgresql_schema,
|
||||
emqx_authz_mongodb_schema,
|
||||
emqx_authz_ldap_schema
|
||||
].
|
||||
|
||||
%% Add more schemas here.
|
||||
customized() ->
|
||||
[].
|
Loading…
Reference in New Issue