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(),
|
emqx_schema:comma_separated_atoms(),
|
||||||
#{
|
#{
|
||||||
mapping => "emqx_machine.applications",
|
mapping => "emqx_machine.applications",
|
||||||
default => [],
|
default => <<"">>,
|
||||||
'readOnly' => true,
|
'readOnly' => true,
|
||||||
importance => ?IMPORTANCE_HIDDEN,
|
importance => ?IMPORTANCE_HIDDEN,
|
||||||
desc => ?DESC(node_applications)
|
desc => ?DESC(node_applications)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_ee_conf, [
|
{application, emqx_ee_conf, [
|
||||||
{description, "EMQX Enterprise Edition configuration schema"},
|
{description, "EMQX Enterprise Edition configuration schema"},
|
||||||
{vsn, "0.1.2"},
|
{vsn, "0.1.3"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
|
|
|
@ -14,14 +14,18 @@ namespace() ->
|
||||||
emqx_conf_schema:namespace().
|
emqx_conf_schema:namespace().
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
|
redefine_roots(
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(Module, Roots) ->
|
fun(Module, Roots) ->
|
||||||
Roots ++ apply(Module, roots, [])
|
Roots ++ apply(Module, roots, [])
|
||||||
end,
|
end,
|
||||||
emqx_conf_schema:roots(),
|
emqx_conf_schema:roots(),
|
||||||
?EE_SCHEMA_MODULES
|
?EE_SCHEMA_MODULES
|
||||||
|
)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
fields("node") ->
|
||||||
|
redefine_node(emqx_conf_schema:fields("node"));
|
||||||
fields(Name) ->
|
fields(Name) ->
|
||||||
emqx_conf_schema:fields(Name).
|
emqx_conf_schema:fields(Name).
|
||||||
|
|
||||||
|
@ -33,3 +37,25 @@ translation(Name) ->
|
||||||
|
|
||||||
validations() ->
|
validations() ->
|
||||||
emqx_conf_schema: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