refactor: redefine default value for 'node.applications' in enterprise
This commit is contained in:
parent
75c8577b6b
commit
3482c2c849
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_ee_conf, [
|
||||
{description, "EMQX Enterprise Edition configuration schema"},
|
||||
{vsn, "0.1.2"},
|
||||
{vsn, "0.1.3"},
|
||||
{registered, []},
|
||||
{applications, [
|
||||
kernel,
|
||||
|
|
|
@ -14,14 +14,18 @@ namespace() ->
|
|||
emqx_conf_schema:namespace().
|
||||
|
||||
roots() ->
|
||||
lists:foldl(
|
||||
fun(Module, Roots) ->
|
||||
Roots ++ apply(Module, roots, [])
|
||||
end,
|
||||
emqx_conf_schema:roots(),
|
||||
?EE_SCHEMA_MODULES
|
||||
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).
|
||||
|
||||
|
@ -33,3 +37,25 @@ 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}]) ->
|
||||
Schema = find_schema(Name, Fields),
|
||||
NewSchema = hocon_schema:override(Schema, Override),
|
||||
replace_schema(Name, NewSchema, Fields).
|
||||
|
||||
find_schema(Name, Fields) ->
|
||||
{Name, Schema} = lists:keyfind(Name, 1, Fields),
|
||||
Schema.
|
||||
|
||||
replace_schema(Name, Schema, Fields) ->
|
||||
lists:keyreplace(Name, 1, Fields, {Name, Schema}).
|
||||
|
|
Loading…
Reference in New Issue