Merge pull request #12226 from zmstone/1222-sync-e5.4.0-build.2-to-master

1222 sync `e5.4.0-build.2` to master
This commit is contained in:
Zaiming (Stone) Shi 2023-12-23 11:22:47 +01:00 committed by GitHub
commit 95194216cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 22 deletions

View File

@ -35,7 +35,7 @@
-define(EMQX_RELEASE_CE, "5.4.0").
%% Enterprise edition
-define(EMQX_RELEASE_EE, "5.4.0-build.1").
-define(EMQX_RELEASE_EE, "5.4.0").
%% The HTTP API version
-define(EMQX_API_VERSION, "5.0").

View File

@ -2,7 +2,7 @@
{application, emqx, [
{id, "emqx"},
{description, "EMQX Core"},
{vsn, "5.1.17"},
{vsn, "5.1.18"},
{modules, []},
{registered, []},
{applications, [

View File

@ -277,24 +277,32 @@ t_ft_disabled(Config) ->
)
).
t_configure(Config) ->
t_configure_1(Config) ->
Uri = uri(["file_transfer"]),
test_configure(Uri, Config).
t_configure_2(Config) ->
Uri = uri(["configs/file_transfer"]),
test_configure(Uri, Config).
test_configure(Uri, Config) ->
?assertMatch(
{ok, 200, #{<<"enable">> := true, <<"storage">> := #{}}},
request_json(get, uri(["file_transfer"]), Config)
request_json(get, Uri, Config)
),
?assertMatch(
{ok, 200, #{<<"enable">> := false}},
request_json(put, uri(["file_transfer"]), #{<<"enable">> => false}, Config)
request_json(put, Uri, #{<<"enable">> => false}, Config)
),
?assertMatch(
{ok, 200, #{<<"enable">> := false}},
request_json(get, uri(["file_transfer"]), Config)
request_json(get, Uri, Config)
),
?assertMatch(
{ok, 200, #{}},
request_json(
put,
uri(["file_transfer"]),
Uri,
#{
<<"enable">> => true,
<<"storage">> => emqx_ft_test_helpers:local_storage(Config)
@ -306,7 +314,7 @@ t_configure(Config) ->
{ok, 400, _},
request(
put,
uri(["file_transfer"]),
Uri,
#{
<<"enable">> => true,
<<"storage">> => #{
@ -321,7 +329,7 @@ t_configure(Config) ->
{ok, 400, _},
request(
put,
uri(["file_transfer"]),
Uri,
#{
<<"enable">> => true,
<<"storage">> => #{
@ -349,7 +357,7 @@ t_configure(Config) ->
{ok, 200, GetConfigJson} =
request_json(
put,
uri(["file_transfer"]),
Uri,
#{
<<"enable">> => true,
<<"storage">> => #{
@ -388,7 +396,7 @@ t_configure(Config) ->
{ok, 400, _},
request_json(
put,
uri(["file_transfer"]),
Uri,
#{
<<"enable">> => true,
<<"storage">> => #{
@ -410,7 +418,7 @@ t_configure(Config) ->
{ok, 200, #{}},
request_json(
put,
uri(["file_transfer"]),
Uri,
emqx_utils_maps:deep_merge(
GetConfigJson,
#{
@ -492,7 +500,12 @@ request_json(Method, Url, Config) ->
request_json(Method, Url, [], Config).
json(Body) when is_binary(Body) ->
emqx_utils_json:decode(Body, [return_maps]).
try
emqx_utils_json:decode(Body, [return_maps])
catch
_:_ ->
error({bad_json, Body})
end.
query(Params) ->
KVs = lists:map(fun({K, V}) -> uri_encode(K) ++ "=" ++ uri_encode(V) end, maps:to_list(Params)),

View File

@ -2,7 +2,7 @@
{application, emqx_management, [
{description, "EMQX Management API and CLI"},
% strict semver, bump manually!
{vsn, "5.0.36"},
{vsn, "5.0.37"},
{modules, []},
{registered, [emqx_management_sup]},
{applications, [

View File

@ -34,7 +34,7 @@
-define(PREFIX, "/configs/").
-define(PREFIX_RESET, "/configs_reset/").
-define(ERR_MSG(MSG), list_to_binary(io_lib:format("~p", [MSG]))).
-define(ERR_MSG(MSG), list_to_binary(io_lib:format("~0p", [MSG]))).
-define(OPTS, #{rawconf_with_defaults => true, override_to => cluster}).
-define(TAGS, ["Configs"]).
@ -267,7 +267,7 @@ schema(Path) ->
'requestBody' => Schema,
responses => #{
200 => Schema,
400 => emqx_dashboard_swagger:error_codes(['UPDATE_FAILED']),
400 => emqx_dashboard_swagger:error_codes(['UPDATE_FAILED', 'INVALID_CONFIG']),
403 => emqx_dashboard_swagger:error_codes(['UPDATE_FAILED'])
}
}
@ -287,11 +287,17 @@ fields(Field) ->
%%%==============================================================================================
%% HTTP API Callbacks
config(get, _Params, Req) ->
[Path] = conf_path(Req),
{200, get_raw_config(Path)};
config(put, #{body := NewConf}, Req) ->
config(Method, Data, Req) ->
Path = conf_path(Req),
do_config(Path, Method, Data).
do_config([<<"file_transfer">> | Path], Method, Data) ->
[] =/= Path andalso throw("file_transfer does no support deep config get/put"),
forward_file_transfer(Method, Data);
do_config([ConfigRoot | Path], get, _Params) ->
[] =/= Path andalso throw("deep config get is not supported"),
{200, get_raw_config(ConfigRoot)};
do_config(Path, put, #{body := NewConf}) ->
case emqx_conf:update(Path, NewConf, ?OPTS) of
{ok, #{raw_config := RawConf}} ->
{200, RawConf};
@ -299,6 +305,19 @@ config(put, #{body := NewConf}, Req) ->
{400, #{code => 'UPDATE_FAILED', message => ?ERR_MSG(Reason)}}
end.
%% @private file_transfer config update reside in this module
%% because it's needed to generate hotconf schema for dashboard UI rendering.
%% As a result of adding "file_transfer" root key to the root keys list
%% there is also a configs/file_transfer http path handler to be implemented.
%% Here we simply forward the call to the file_transfer API module.
-if(?EMQX_RELEASE_EDITION == ee).
forward_file_transfer(Method, Data) ->
emqx_ft_api:'/file_transfer'(Method, Data).
-else.
forward_file_transfer(_Method, _Data) ->
{400, #{code => 'BAD_REQUEST', message => <<"not supported">>}}.
-endif.
global_zone_configs(get, _Params, _Req) ->
{200, get_zones()};
global_zone_configs(put, #{body := Body}, _Req) ->

View File

@ -14,8 +14,8 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 5.4.0-build.1
version: 5.4.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 5.4.0-build.1
appVersion: 5.4.0