style: make elvis happy

This commit is contained in:
JimMoen 2021-12-01 15:47:56 +08:00
parent d7ec368884
commit effa3b8b90
1 changed files with 12 additions and 19 deletions

View File

@ -116,26 +116,11 @@ fields(mnesia) ->
default => true}} default => true}}
]; ];
fields(mongo_single) -> fields(mongo_single) ->
[ {collection, #{type => atom()}} mongo_common_fields() ++ emqx_connector_mongo:fields(single);
, {selector, #{type => map()}}
, {type, #{type => mongodb}}
, {enable, #{type => boolean(),
default => true}}
] ++ emqx_connector_mongo:fields(single);
fields(mongo_rs) -> fields(mongo_rs) ->
[ {collection, #{type => atom()}} mongo_common_fields() ++ emqx_connector_mongo:fields(rs);
, {selector, #{type => map()}}
, {type, #{type => mongodb}}
, {enable, #{type => boolean(),
default => true}}
] ++ emqx_connector_mongo:fields(rs);
fields(mongo_sharded) -> fields(mongo_sharded) ->
[ {collection, #{type => atom()}} mongo_common_fields() ++ emqx_connector_mongo:fields(sharded);
, {selector, #{type => map()}}
, {type, #{type => mongodb}}
, {enable, #{type => boolean(),
default => true}}
] ++ emqx_connector_mongo:fields(sharded);
fields(mysql) -> fields(mysql) ->
connector_fields(mysql) ++ connector_fields(mysql) ++
[ {query, query()} ]; [ {query, query()} ];
@ -163,6 +148,14 @@ http_common_fields() ->
, {body, #{type => map(), nullable => true}} , {body, #{type => map(), nullable => true}}
] ++ proplists:delete(base_url, emqx_connector_http:fields(config)). ] ++ proplists:delete(base_url, emqx_connector_http:fields(config)).
mongo_common_fields() ->
[ {collection, #{type => atom()}}
, {selector, #{type => map()}}
, {type, #{type => mongodb}}
, {enable, #{type => boolean(),
default => true}}
].
validations() -> validations() ->
[ {check_ssl_opts, fun check_ssl_opts/1} [ {check_ssl_opts, fun check_ssl_opts/1}
, {check_headers, fun check_headers/1} , {check_headers, fun check_headers/1}
@ -250,7 +243,7 @@ connector_fields(DB, Fields) ->
[ {type, #{type => DB}} [ {type, #{type => DB}}
, {enable, #{type => boolean(), , {enable, #{type => boolean(),
default => true}} default => true}}
] ++ Mod:fields(Fields). ] ++ erlang:apply(Mod, fields, [Fields]).
to_list(A) when is_atom(A) -> to_list(A) when is_atom(A) ->
atom_to_list(A); atom_to_list(A);