refactor(eqmx_config): use dynamic callback to upgrade raw config
This commit is contained in:
parent
38bf2ae445
commit
96726b5620
|
@ -325,7 +325,7 @@ init_load(SchemaMod, Conf) when is_list(Conf) orelse is_binary(Conf) ->
|
|||
ok = save_schema_mod_and_names(SchemaMod),
|
||||
HasDeprecatedFile = has_deprecated_file(),
|
||||
RawConf0 = load_config_files(HasDeprecatedFile, Conf),
|
||||
RawConf1 = emqx_connector_schema:transform_bridges_v1_to_connectors_and_bridges_v2(RawConf0),
|
||||
RawConf1 = apply(SchemaMod, upgrade_raw_conf, [RawConf0]),
|
||||
warning_deprecated_root_key(RawConf1),
|
||||
RawConf2 =
|
||||
case HasDeprecatedFile of
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
-export([password_converter/2, bin_str_converter/2]).
|
||||
-export([authz_fields/0]).
|
||||
-export([sc/2, map/2]).
|
||||
-export([upgrade_raw_conf/1]).
|
||||
|
||||
-elvis([{elvis_style, god_modules, disable}]).
|
||||
|
||||
|
@ -182,6 +183,10 @@
|
|||
-define(DEFAULT_MULTIPLIER, 1.5).
|
||||
-define(DEFAULT_BACKOFF, 0.75).
|
||||
|
||||
%% dummy callback from eqmx_config:init_load
|
||||
upgrade_raw_conf(RawConf) ->
|
||||
RawConf.
|
||||
|
||||
namespace() -> broker.
|
||||
|
||||
tags() ->
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0, desc/1, tags/0
|
||||
]).
|
||||
-export([conf_get/2, conf_get/3, keys/2, filter/1]).
|
||||
-export([upgrade_raw_conf/1]).
|
||||
|
||||
%% internal exports for `emqx_enterprise_schema' only.
|
||||
-export([ensure_unicode_path/2, convert_rotation/2, log_handler_common_confs/2]).
|
||||
|
@ -81,6 +82,10 @@
|
|||
%% 1 million default ports counter
|
||||
-define(DEFAULT_MAX_PORTS, 1024 * 1024).
|
||||
|
||||
%% Callback to upgrade config after loaded from config file but before validation.
|
||||
upgrade_raw_conf(RawConf) ->
|
||||
emqx_connector_schema:transform_bridges_v1_to_connectors_and_bridges_v2(RawConf).
|
||||
|
||||
%% root config should not have a namespace
|
||||
namespace() -> undefined.
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
-include_lib("hocon/include/hoconsc.hrl").
|
||||
|
||||
-export([namespace/0, roots/0, fields/1, translations/0, translation/1, desc/1, validations/0]).
|
||||
-export([upgrade_raw_conf/1]).
|
||||
|
||||
-define(EE_SCHEMA_MODULES, [
|
||||
emqx_license_schema,
|
||||
|
@ -17,6 +18,10 @@
|
|||
emqx_ft_schema
|
||||
]).
|
||||
|
||||
%% Callback to upgrade config after loaded from config file but before validation.
|
||||
upgrade_raw_conf(RawConf) ->
|
||||
emqx_conf_schema:upgrade_raw_conf(RawConf).
|
||||
|
||||
namespace() ->
|
||||
emqx_conf_schema:namespace().
|
||||
|
||||
|
|
Loading…
Reference in New Issue