Merge pull request #8890 from zhongwencool/add-edition-to-nodes-api
feat: add edition info to /nodes api
This commit is contained in:
commit
f6e55a5f7b
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
edition/0,
|
edition/0,
|
||||||
|
edition_longstr/0,
|
||||||
description/0,
|
description/0,
|
||||||
version/0
|
version/0
|
||||||
]).
|
]).
|
||||||
|
@ -44,8 +45,12 @@ description() ->
|
||||||
-spec edition() -> ce | ee.
|
-spec edition() -> ce | ee.
|
||||||
-ifdef(EMQX_RELEASE_EDITION).
|
-ifdef(EMQX_RELEASE_EDITION).
|
||||||
edition() -> ?EMQX_RELEASE_EDITION.
|
edition() -> ?EMQX_RELEASE_EDITION.
|
||||||
|
|
||||||
|
edition_longstr() -> <<"Enterprise">>.
|
||||||
-else.
|
-else.
|
||||||
edition() -> ce.
|
edition() -> ce.
|
||||||
|
|
||||||
|
edition_longstr() -> <<"Opensource">>.
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
%% @doc Return the release version.
|
%% @doc Return the release version.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{id, "emqx_machine"},
|
{id, "emqx_machine"},
|
||||||
{description, "The EMQX Machine"},
|
{description, "The EMQX Machine"},
|
||||||
% strict semver, bump manually!
|
% strict semver, bump manually!
|
||||||
{vsn, "0.1.0"},
|
{vsn, "0.1.1"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib]},
|
{applications, [kernel, stdlib]},
|
||||||
|
|
|
@ -45,9 +45,10 @@ set_prompt_func() ->
|
||||||
prompt_func(PropList) ->
|
prompt_func(PropList) ->
|
||||||
Line = proplists:get_value(history, PropList, 1),
|
Line = proplists:get_value(history, PropList, 1),
|
||||||
Version = emqx_release:version(),
|
Version = emqx_release:version(),
|
||||||
|
Edition = emqx_release:edition(),
|
||||||
case is_alive() of
|
case is_alive() of
|
||||||
true -> io_lib:format(<<"~ts(~s)~w> ">>, [Version, node(), Line]);
|
true -> io_lib:format(<<"~ts-~ts(~s)~w> ">>, [Edition, Version, node(), Line]);
|
||||||
false -> io_lib:format(<<"~ts ~w> ">>, [Version, Line])
|
false -> io_lib:format(<<"~ts-~ts ~w> ">>, [Edition, Version, Line])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
local_allowed(MF, Args, State) ->
|
local_allowed(MF, Args, State) ->
|
||||||
|
|
|
@ -141,6 +141,7 @@ node_info() ->
|
||||||
node_status => 'running',
|
node_status => 'running',
|
||||||
uptime => proplists:get_value(uptime, BrokerInfo),
|
uptime => proplists:get_value(uptime, BrokerInfo),
|
||||||
version => iolist_to_binary(proplists:get_value(version, BrokerInfo)),
|
version => iolist_to_binary(proplists:get_value(version, BrokerInfo)),
|
||||||
|
edition => emqx_release:edition_longstr(),
|
||||||
role => mria_rlog:role()
|
role => mria_rlog:role()
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,12 @@ fields(node_info) ->
|
||||||
{version,
|
{version,
|
||||||
mk(
|
mk(
|
||||||
string(),
|
string(),
|
||||||
#{desc => <<"Release version">>, example => "5.0.0-beat.3-00000000"}
|
#{desc => <<"Release version">>, example => "5.0.0"}
|
||||||
|
)},
|
||||||
|
{edition,
|
||||||
|
mk(
|
||||||
|
enum(['Opensource', 'Enterprise']),
|
||||||
|
#{desc => <<"Release edition">>, example => "Opensource"}
|
||||||
)},
|
)},
|
||||||
{sys_path,
|
{sys_path,
|
||||||
mk(
|
mk(
|
||||||
|
|
|
@ -57,6 +57,8 @@ t_nodes_api(_) ->
|
||||||
LocalNodeInfo = hd(NodesResponse),
|
LocalNodeInfo = hd(NodesResponse),
|
||||||
Node = binary_to_atom(maps:get(<<"node">>, LocalNodeInfo), utf8),
|
Node = binary_to_atom(maps:get(<<"node">>, LocalNodeInfo), utf8),
|
||||||
?assertEqual(Node, node()),
|
?assertEqual(Node, node()),
|
||||||
|
Edition = maps:get(<<"edition">>, LocalNodeInfo),
|
||||||
|
?assertEqual(emqx_release:edition_longstr(), Edition),
|
||||||
|
|
||||||
NodePath = emqx_mgmt_api_test_util:api_path(["nodes", atom_to_list(node())]),
|
NodePath = emqx_mgmt_api_test_util:api_path(["nodes", atom_to_list(node())]),
|
||||||
{ok, NodeInfo} = emqx_mgmt_api_test_util:request_api(get, NodePath),
|
{ok, NodeInfo} = emqx_mgmt_api_test_util:request_api(get, NodePath),
|
||||||
|
|
Loading…
Reference in New Issue