fix(s3-bridge): report inconsistent `min/max_part_size` option
This commit is contained in:
parent
8279d8c787
commit
28f6eb0200
|
@ -69,7 +69,11 @@ fields(?ACTION) ->
|
|||
}),
|
||||
#{
|
||||
required => true,
|
||||
desc => ?DESC(s3_upload)
|
||||
desc => ?DESC(s3_upload),
|
||||
%% NOTE
|
||||
%% There seems to be no way to attach validators to union types, thus we
|
||||
%% have to attach a "common denominator" validator here.
|
||||
validator => validators(s3_upload_parameters)
|
||||
}
|
||||
),
|
||||
#{
|
||||
|
@ -211,6 +215,9 @@ desc(s3_upload_resource_opts) ->
|
|||
desc(_Name) ->
|
||||
undefined.
|
||||
|
||||
validators(s3_upload_parameters) ->
|
||||
emqx_s3_schema:validators(s3_uploader).
|
||||
|
||||
convert_actions(Conf = #{}, Opts) ->
|
||||
maps:map(fun(_Name, ConfAction) -> convert_action(ConfAction, Opts) end, Conf);
|
||||
convert_actions(undefined, _) ->
|
||||
|
|
|
@ -156,6 +156,24 @@ t_create_via_http(Config) ->
|
|||
t_on_get_status(Config) ->
|
||||
emqx_bridge_v2_testlib:t_on_get_status(Config, #{}).
|
||||
|
||||
t_invalid_config(Config) ->
|
||||
?assertMatch(
|
||||
{error,
|
||||
{_Status, _, #{
|
||||
<<"code">> := <<"BAD_REQUEST">>,
|
||||
<<"message">> := #{<<"kind">> := <<"validation_error">>}
|
||||
}}},
|
||||
emqx_bridge_v2_testlib:create_bridge_api(
|
||||
Config,
|
||||
_Overrides = #{
|
||||
<<"parameters">> => #{
|
||||
<<"min_part_size">> => <<"5GB">>,
|
||||
<<"max_part_size">> => <<"100MB">>
|
||||
}
|
||||
}
|
||||
)
|
||||
).
|
||||
|
||||
t_aggreg_upload(Config) ->
|
||||
Bucket = ?config(s3_bucket, Config),
|
||||
BridgeName = ?config(bridge_name, Config),
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
-import(hoconsc, [mk/2, ref/2]).
|
||||
|
||||
-export([roots/0, fields/1, namespace/0, tags/0, desc/1]).
|
||||
-export([validators/1]).
|
||||
|
||||
-export([translate/1]).
|
||||
-export([translate/2]).
|
||||
|
@ -177,6 +178,14 @@ desc(s3_upload) ->
|
|||
desc(transport_options) ->
|
||||
"Options for the HTTP transport layer used by the S3 client".
|
||||
|
||||
validators(s3_uploader) ->
|
||||
[fun validate_part_size/1].
|
||||
|
||||
validate_part_size(Conf) ->
|
||||
Min = hocon_maps:get(<<"min_part_size">>, Conf),
|
||||
Max = hocon_maps:get(<<"max_part_size">>, Conf),
|
||||
Min =< Max orelse {error, <<"Inconsistent 'min_part_size': cannot exceed 'max_part_size'">>}.
|
||||
|
||||
translate(Conf) ->
|
||||
translate(Conf, #{}).
|
||||
|
||||
|
|
Loading…
Reference in New Issue