From 13b67c0d19cb695044fa710571ad31f3858ea0e4 Mon Sep 17 00:00:00 2001 From: Ayodele Date: Wed, 25 Nov 2020 21:33:38 +0100 Subject: [PATCH] Umbrella fix build (#5) * fix(emqx_auth_jwt): Dialyzer warnings * fix(emqx_auth_mnesia_cli): Dialyzer warnings * fix(emqx_bridge_mqtt_cli): Dialyzer warnings * fix(emqx_bridge_mqtt_cli): Dialyzer warnings * fix(emqx_auth_redis_sup): Dialyzer warnings * fix(emqx_bridge_mqtt): Dialyzer warnings * fix(emqx_auth_pgsql_cli): Dialyzer warnings * fix(emqx_bridge_mqtt_cli): Dialyzer warnings * fix(emqx_auth_mnesia_cli): Dialyzer warnings --- .../src/emqx_auth_mnesia_cli.erl | 6 ++++++ .../src/emqx_auth_pgsql_cli.erl | 4 ++++ apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl | 5 ++--- .../src/emqx_bridge_mqtt_cli.erl | 18 ++++++------------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/emqx_auth_mnesia/src/emqx_auth_mnesia_cli.erl b/apps/emqx_auth_mnesia/src/emqx_auth_mnesia_cli.erl index cd31675aa..d6a8e8cb4 100644 --- a/apps/emqx_auth_mnesia/src/emqx_auth_mnesia_cli.erl +++ b/apps/emqx_auth_mnesia/src/emqx_auth_mnesia_cli.erl @@ -156,11 +156,17 @@ auth_username_cli(["add", Username, Password]) -> {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason]) end; +<<<<<<< HEAD auth_username_cli(["update", Username, NewPassword]) -> case update_user({username, iolist_to_binary(Username)}, iolist_to_binary(NewPassword)) of ok -> emqx_ctl:print("ok~n"); {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason]) end; +======= +acl_cli(["del", Login, Topic])-> + ok = remove_acl(iolist_to_binary(Login), iolist_to_binary(Topic)), + emqx_ctl:print("ok~n"); +>>>>>>> bb37bac5... Umbrella fix build (#5) auth_username_cli(["del", Username]) -> case remove_user({username, iolist_to_binary(Username)}) of diff --git a/apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl b/apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl index 27d25f35b..fdfd1b9b8 100644 --- a/apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl +++ b/apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl @@ -29,6 +29,8 @@ , equery/3 ]). +-type client_info() :: #{username:=_, clientid:=_, peerhost:=_, _=>_}. + %%-------------------------------------------------------------------- %% Avoid SQL Injection: Parse SQL to Parameter Query. %%-------------------------------------------------------------------- @@ -104,9 +106,11 @@ conn_opts([Opt = {ssl_opts, _}|Opts], Acc) -> conn_opts([_Opt|Opts], Acc) -> conn_opts(Opts, Acc). +-spec(equery(atom(), string() | epgsql:statement(), Parameters::[any()]) -> {ok, ColumnsDescription :: [any()], RowsValues :: [any()]} | {error, any()} ). equery(Pool, Sql, Params) -> ecpool:with_client(Pool, fun(C) -> epgsql:prepared_query(C, Sql, Params) end). +-spec(equery(atom(), string() | epgsql:statement(), Parameters::[any()], client_info()) -> {ok, ColumnsDescription :: [any()], RowsValues :: [any()]} | {error, any()} ). equery(Pool, Sql, Params, ClientInfo) -> ecpool:with_client(Pool, fun(C) -> epgsql:prepared_query(C, Sql, replvar(Params, ClientInfo)) end). diff --git a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl index 19c0c5711..c5f688753 100644 --- a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl +++ b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl @@ -186,6 +186,5 @@ replvar([Key|More], Options) -> %% ${node} => node() feedvar(clientid, ClientId, _) -> - iolist_to_binary(re:replace(ClientId, "\\${node}", atom_to_list(node()))); -feedvar(_, Val, _) -> - Val. + iolist_to_binary(re:replace(ClientId, "\\${node}", atom_to_list(node()))). + diff --git a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_cli.erl b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_cli.erl index 1ee5a90c6..c6d6e2378 100644 --- a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_cli.erl +++ b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_cli.erl @@ -56,16 +56,12 @@ cli(["forwards", Name]) -> end, emqx_bridge_worker:get_forwards(Name)); cli(["add-forward", Name, Topic]) -> - case emqx_bridge_worker:ensure_forward_present(Name, iolist_to_binary(Topic)) of - ok -> emqx_ctl:print("Add-forward topic successfully.~n"); - {error, Reason} -> emqx_ctl:print("Add-forward failed reason: ~p.~n", [Reason]) - end; + ok = emqx_bridge_worker:ensure_forward_present(Name, iolist_to_binary(Topic)), + emqx_ctl:print("Add-forward topic successfully.~n"); cli(["del-forward", Name, Topic]) -> - case emqx_bridge_worker:ensure_forward_absent(Name, iolist_to_binary(Topic)) of - ok -> emqx_ctl:print("Del-forward topic successfully.~n"); - {error, Reason} -> emqx_ctl:print("Del-forward failed reason: ~p.~n", [Reason]) - end; + ok = emqx_bridge_worker:ensure_forward_absent(Name, iolist_to_binary(Topic)), + emqx_ctl:print("Del-forward topic successfully.~n"); cli(["subscriptions", Name]) -> foreach(fun({Topic, Qos}) -> @@ -79,10 +75,8 @@ cli(["add-subscription", Name, Topic, Qos]) -> end; cli(["del-subscription", Name, Topic]) -> - case emqx_bridge_worker:ensure_subscription_absent(Name, Topic) of - ok -> emqx_ctl:print("Del-subscription topic successfully.~n"); - {error, Reason} -> emqx_ctl:print("Del-subscription failed reason: ~p.~n", [Reason]) - end; + ok = emqx_bridge_worker:ensure_subscription_absent(Name, Topic), + emqx_ctl:print("Del-subscription topic successfully.~n"); cli(_) -> emqx_ctl:usage([{"bridges list", "List bridges"},