Merge pull request #8073 from terry-xiaoyu/rule_name_optional
fix: make 'name' field optional
This commit is contained in:
commit
4bc58548aa
|
@ -106,10 +106,13 @@ end).
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
application:ensure_all_started(grpc),
|
application:ensure_all_started(grpc),
|
||||||
[start_channel(), start_server()].
|
[ensure_channel(), start_server()].
|
||||||
|
|
||||||
start_channel() ->
|
ensure_channel() ->
|
||||||
grpc_client_sup:create_channel_pool(ct_test_channel, "http://127.0.0.1:9100", #{}).
|
case grpc_client_sup:create_channel_pool(ct_test_channel, "http://127.0.0.1:9100", #{}) of
|
||||||
|
{error, {already_started, Pid}} -> {ok, Pid};
|
||||||
|
{ok, Pid} -> {ok, Pid}
|
||||||
|
end.
|
||||||
|
|
||||||
start_server() ->
|
start_server() ->
|
||||||
Services = #{
|
Services = #{
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
desc/1
|
desc/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([validate_sql/1, validate_rule_name/1]).
|
-export([validate_sql/1]).
|
||||||
|
|
||||||
namespace() -> rule_engine.
|
namespace() -> rule_engine.
|
||||||
|
|
||||||
|
@ -187,26 +187,11 @@ rule_name() ->
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("rules_name"),
|
desc => ?DESC("rules_name"),
|
||||||
default => "",
|
default => "",
|
||||||
required => true,
|
required => false,
|
||||||
example => "foo",
|
example => "foo"
|
||||||
validator => fun ?MODULE:validate_rule_name/1
|
|
||||||
}
|
}
|
||||||
)}.
|
)}.
|
||||||
|
|
||||||
validate_rule_name(Name) ->
|
|
||||||
RE = "^[A-Za-z0-9]+[A-Za-z0-9-_]*$",
|
|
||||||
try re:run(Name, RE) of
|
|
||||||
{match, _} ->
|
|
||||||
ok;
|
|
||||||
_Nomatch ->
|
|
||||||
Reason = list_to_binary(io_lib:format("Bad rule name ~p, expect ~p", [Name, RE])),
|
|
||||||
{error, Reason}
|
|
||||||
catch
|
|
||||||
_:_ ->
|
|
||||||
Reason = list_to_binary(io_lib:format("Bad rule name ~p, expect ~p", [Name, RE])),
|
|
||||||
{error, Reason}
|
|
||||||
end.
|
|
||||||
|
|
||||||
actions() ->
|
actions() ->
|
||||||
[
|
[
|
||||||
binary(),
|
binary(),
|
||||||
|
|
Loading…
Reference in New Issue