fix(config): do not allow default values for configs in zones
This commit is contained in:
parent
7b63f7f18b
commit
005332d45d
|
@ -979,6 +979,9 @@ quota {
|
||||||
## - `flapping_detect.*`
|
## - `flapping_detect.*`
|
||||||
## - `force_shutdown.*`
|
## - `force_shutdown.*`
|
||||||
## - `conn_congestion.*`
|
## - `conn_congestion.*`
|
||||||
|
## - `rate_limit.*`
|
||||||
|
## - `quota.*`
|
||||||
|
## - `force_gc.*`
|
||||||
##
|
##
|
||||||
## syntax: zones.<zone-name>
|
## syntax: zones.<zone-name>
|
||||||
## example: zones.my_zone
|
## example: zones.my_zone
|
||||||
|
|
|
@ -126,19 +126,14 @@ fields("zones") ->
|
||||||
[ {"$name", ref("zone_settings")}];
|
[ {"$name", ref("zone_settings")}];
|
||||||
|
|
||||||
fields("zone_settings") ->
|
fields("zone_settings") ->
|
||||||
[ {"mqtt", ref("mqtt")}
|
Fields = ["mqtt", "stats", "authorization", "flapping_detect", "force_shutdown",
|
||||||
, {"stats", ref("stats")}
|
"conn_congestion", "rate_limit", "quota", "force_gc"],
|
||||||
, {"flapping_detect", ref("flapping_detect")}
|
[{F, ref("strip_default:" ++ F)} || F <- Fields];
|
||||||
, {"force_shutdown", ref("force_shutdown")}
|
|
||||||
, {"conn_congestion", ref("conn_congestion")}
|
|
||||||
, {"force_gc", ref("force_gc")}
|
|
||||||
];
|
|
||||||
|
|
||||||
fields("rate_limit") ->
|
fields("rate_limit") ->
|
||||||
[ {"max_conn_rate", maybe_infinity(integer(), 1000)}
|
[ {"max_conn_rate", maybe_infinity(integer(), 1000)}
|
||||||
, {"conn_messages_in", maybe_infinity(comma_separated_list())}
|
, {"conn_messages_in", maybe_infinity(comma_separated_list())}
|
||||||
, {"conn_bytes_in", maybe_infinity(comma_separated_list())}
|
, {"conn_bytes_in", maybe_infinity(comma_separated_list())}
|
||||||
, {"quota", ref("quota")}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
fields("quota") ->
|
fields("quota") ->
|
||||||
|
@ -334,7 +329,10 @@ fields("alarm") ->
|
||||||
[ {"actions", t(hoconsc:array(atom()), undefined, [log, publish])}
|
[ {"actions", t(hoconsc:array(atom()), undefined, [log, publish])}
|
||||||
, {"size_limit", t(integer(), undefined, 1000)}
|
, {"size_limit", t(integer(), undefined, 1000)}
|
||||||
, {"validity_period", t(duration(), undefined, "24h")}
|
, {"validity_period", t(duration(), undefined, "24h")}
|
||||||
].
|
];
|
||||||
|
|
||||||
|
fields("strip_default:" ++ Name) ->
|
||||||
|
strip_default(fields(Name)).
|
||||||
|
|
||||||
mqtt_listener() ->
|
mqtt_listener() ->
|
||||||
base_listener() ++
|
base_listener() ++
|
||||||
|
@ -547,6 +545,19 @@ to_erl_cipher_suite(Str) ->
|
||||||
Cipher -> Cipher
|
Cipher -> Cipher
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
strip_default(Fields) ->
|
||||||
|
[do_strip_default(F) || F <- Fields].
|
||||||
|
|
||||||
|
do_strip_default({Name, #{type := {ref, Ref}}}) ->
|
||||||
|
{Name, nullable_no_def(ref("strip_default:" ++ Ref))};
|
||||||
|
do_strip_default({Name, #{type := {ref, _Mod, Ref}}}) ->
|
||||||
|
{Name, nullable_no_def(ref("strip_default:" ++ Ref))};
|
||||||
|
do_strip_default({Name, Type}) ->
|
||||||
|
{Name, nullable_no_def(Type)}.
|
||||||
|
|
||||||
|
nullable_no_def(Type) when is_map(Type) ->
|
||||||
|
Type#{default => undefined, nullable => true}.
|
||||||
|
|
||||||
to_atom(Atom) when is_atom(Atom) ->
|
to_atom(Atom) when is_atom(Atom) ->
|
||||||
Atom;
|
Atom;
|
||||||
to_atom(Str) when is_list(Str) ->
|
to_atom(Str) when is_list(Str) ->
|
||||||
|
|
Loading…
Reference in New Issue