Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Commit 724e610

Browse files
author
Brujo Benavides
authored
Merge pull request #11 from SemanticSugar/RTI-5175-OTP21
[RTI-5175] Remove discrepancies found by dialyzer on OTP21
2 parents 4eb7147 + e546b9d commit 724e610

6 files changed

Lines changed: 42 additions & 58 deletions

File tree

src/erlcloud_aws.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
profile/0, profile/1, profile/2
2828
]).
2929

30+
%% We're abusing application:get_env there
31+
-dialyzer([{nowarn_function, [get_role_credentials/1, get_credentials_from_role/1,
32+
clear_expired_configs/0, clear_config/1,
33+
auto_config_task_metadata/0, auto_config_metadata/0
34+
]}]).
35+
3036
-include("erlcloud.hrl").
3137
-include("erlcloud_aws.hrl").
3238

src/erlcloud_ddb_util.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ batch_write_retry(RequestItems, Config) ->
513513
%% @end
514514
%%------------------------------------------------------------------------------
515515

516-
-spec wait_for_table_active(table_name(), pos_integer() | infinity, non_neg_integer(), aws_config()) ->
516+
-spec wait_for_table_active(table_name(), pos_integer() | infinity, non_neg_integer() | infinity, aws_config()) ->
517517
ok | {error, deleting | retry_threshold_exceeded | any()}.
518518
wait_for_table_active(Table, Interval, RetryTimes, Config) when is_binary(Table), Interval > 0, RetryTimes >= 0 ->
519519
case erlcloud_ddb2:describe_table(Table, [{out, record}], Config) of

src/erlcloud_elb.erl

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,18 @@ describe_load_balancers_all(Names) ->
254254
-spec describe_load_balancers_all(list(string()), aws_config()) ->
255255
{ok, [term()]} | {error, term()}.
256256
describe_load_balancers_all(Names, Config) ->
257-
describe_all(
258-
fun(Marker, Cfg) ->
259-
describe_load_balancers(
260-
Names, ?DEFAULT_MAX_RECORDS, Marker, Cfg
261-
)
262-
end, Config, none, []).
263-
264-
257+
describe_load_balancers_all(Names, Config, none, []).
258+
259+
describe_load_balancers_all(Names, AwsConfig, Marker, Acc) ->
260+
case describe_load_balancers(Names, ?DEFAULT_MAX_RECORDS, Marker, AwsConfig) of
261+
{ok, Res} ->
262+
{ok, lists:append(Acc, Res)};
263+
{{paged, NewMarker}, Res} ->
264+
describe_load_balancers_all(Names, AwsConfig, NewMarker, lists:append(Acc, Res));
265+
{error, Reason} ->
266+
{error, Reason}
267+
end.
268+
265269
extract_elb(Item) ->
266270
[
267271
{load_balancer_name, get_text("LoadBalancerName", Item)},
@@ -541,19 +545,6 @@ delete_load_balancer_policy(LB, PolicyName, Config) when is_list(LB),
541545
member_params(Prefix, MemberIdentifiers) ->
542546
MemberKeys = [Prefix ++ integer_to_list(I) || I <- lists:seq(1, length(MemberIdentifiers))],
543547
[{K, V} || {K, V} <- lists:zip(MemberKeys, MemberIdentifiers)].
544-
545-
546-
describe_all(Fun, AwsConfig, Marker, Acc) ->
547-
case Fun(Marker, AwsConfig) of
548-
{ok, Res} ->
549-
{ok, lists:append(Acc, Res)};
550-
{ok, Res, NewMarker} ->
551-
describe_all(Fun, AwsConfig, NewMarker, lists:append(Acc, Res));
552-
{{paged, NewMarker}, Res} ->
553-
describe_all(Fun, AwsConfig, NewMarker, lists:append(Acc, Res));
554-
{error, Reason} ->
555-
{error, Reason}
556-
end.
557548

558549

559550
elb_query(Config, Action, Params) ->

src/erlcloud_guardduty.erl

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ get_detector(DetectorId) ->
6060
Config :: aws_config()) -> gd_return().
6161
get_detector(DetectorId, Config) ->
6262
Path = "/detector/" ++ binary_to_list(DetectorId),
63-
guardduty_request(Config, get, Path, undefined).
63+
guardduty_request(Config, get, Path).
6464

6565

6666
%%------------------------------------------------------------------------------
@@ -77,63 +77,50 @@ list_detectors() -> list_detectors(default_config()).
7777
list_detectors(Config) ->
7878
list_detectors(undefined, undefined, Config).
7979

80-
-spec list_detectors(Marker :: binary(),
81-
MaxItems :: integer()) -> gd_return().
80+
-spec list_detectors(Marker :: undefined | binary(),
81+
MaxItems :: undefined | integer()) -> gd_return().
8282
list_detectors(Marker, MaxItems) ->
8383
list_detectors(Marker, MaxItems, default_config()).
8484

85-
-spec list_detectors(Marker :: binary(),
86-
MaxItems :: integer(),
85+
-spec list_detectors(Marker :: undefined | binary(),
86+
MaxItems :: undefined | integer(),
8787
Config :: aws_config()) -> gd_return().
8888
list_detectors(Marker, MaxItems, Config) ->
8989
Path = "/detector",
9090
QParams = filter_undef([{"Marker", Marker},
9191
{"MaxItems", MaxItems}]),
92-
guardduty_request(Config, get, Path, undefined, QParams).
92+
guardduty_request(Config, get, Path, QParams).
9393

9494

9595
%%%------------------------------------------------------------------------------
9696
%%% Internal Functions
9797
%%%------------------------------------------------------------------------------
9898

99-
guardduty_request(Config, Method, Path, Body) ->
100-
guardduty_request(Config, Method, Path, Body, []).
99+
guardduty_request(Config, Method, Path) ->
100+
guardduty_request(Config, Method, Path, []).
101101

102-
guardduty_request(Config, Method, Path, Body, QParam) ->
102+
guardduty_request(Config, Method, Path, QParam) ->
103103
case erlcloud_aws:update_config(Config) of
104104
{ok, Config1} ->
105-
guardduty_request_no_update(Config1, Method, Path, Body, QParam);
105+
guardduty_request_no_update(Config1, Method, Path, QParam);
106106
{error, Reason} ->
107107
{error, Reason}
108108
end.
109109

110-
guardduty_request_no_update(Config, Method, Path, Body, QParam) ->
111-
Form = case encode_body(Body) of
112-
<<>> -> erlcloud_http:make_query_string(QParam);
113-
Value -> Value
114-
end,
115-
Headers = headers(Method, Path, Config, encode_body(Body), QParam),
110+
guardduty_request_no_update(Config, Method, Path, QParam) ->
111+
Headers = headers(Method, Path, Config, QParam),
116112
case erlcloud_aws:aws_request_form_raw(
117113
Method, Config#aws_config.guardduty_scheme, Config#aws_config.guardduty_host,
118-
Config#aws_config.guardduty_port, Path, Form, Headers, Config) of
114+
Config#aws_config.guardduty_port, Path, <<>>, Headers, Config) of
119115
{ok, Data} ->
120116
{ok, jsx:decode(Data)};
121117
E ->
122118
E
123119
end.
124120

125-
encode_body(undefined) ->
126-
<<>>;
127-
encode_body([]) ->
128-
<<"{}">>;
129-
encode_body(Body) ->
130-
jsx:encode(Body).
131-
132-
headers(Method, Uri, Config, Body, QParam) ->
133-
Headers = [{"host", Config#aws_config.guardduty_host},
134-
{"content-type", "application/json"}],
121+
headers(Method, Uri, Config, QParam) ->
122+
Headers = [{"host", Config#aws_config.guardduty_host}, {"content-type", "application/json"}],
135123
Region = erlcloud_aws:aws_region_from_host(Config#aws_config.guardduty_host),
136-
erlcloud_aws:sign_v4(Method, Uri, Config,
137-
Headers, Body, Region, "guardduty", QParam).
124+
erlcloud_aws:sign_v4(Method, Uri, Config, Headers, <<>>, Region, "guardduty", QParam).
138125

139126
default_config() -> erlcloud_aws:default_config().

src/erlcloud_iam.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,19 +774,19 @@ list_virtual_mfa_devices(#aws_config{} = Config) ->
774774
list_virtual_mfa_devices(AssignmentStatus) ->
775775
list_virtual_mfa_devices(AssignmentStatus, undefined, undefined, default_config()).
776776

777-
-spec list_virtual_mfa_devices(string(), string() | aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
777+
-spec list_virtual_mfa_devices(undefined | string(), string() | aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
778778
list_virtual_mfa_devices(AssignmentStatus, #aws_config{} = Config) ->
779779
list_virtual_mfa_devices(AssignmentStatus, undefined, undefined, Config);
780780
list_virtual_mfa_devices(AssignmentStatus, Marker) ->
781781
list_virtual_mfa_devices(AssignmentStatus, Marker, undefined, default_config()).
782782

783-
-spec list_virtual_mfa_devices(string(), string(), string()| aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
783+
-spec list_virtual_mfa_devices(undefined | string(), undefined | string(), string()| aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
784784
list_virtual_mfa_devices(AssignmentStatus, Marker, #aws_config{} = Config) ->
785785
list_virtual_mfa_devices(AssignmentStatus, Marker, undefined, Config);
786786
list_virtual_mfa_devices(AssignmentStatus, Marker, MaxItems) ->
787787
list_virtual_mfa_devices(AssignmentStatus, Marker, MaxItems, default_config()).
788788

789-
-spec list_virtual_mfa_devices(string(), string(), string(), aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
789+
-spec list_virtual_mfa_devices(undefined | string(), undefined | string(), undefined | string(), aws_config()) -> {ok, proplist()} | {ok, proplist(), string()} | {error, any()}.
790790
list_virtual_mfa_devices(AssignmentStatus, Marker, MaxItems, #aws_config{} = Config) ->
791791
Params = make_list_virtual_mfa_devices_params(AssignmentStatus, Marker, MaxItems),
792792
ItemPath = "/ListVirtualMFADevicesResponse/ListVirtualMFADevicesResult/VirtualMFADevices/member",
@@ -803,7 +803,7 @@ list_virtual_mfa_devices_all(#aws_config{} = Config) ->
803803
list_virtual_mfa_devices_all(AssignmentStatus) ->
804804
list_virtual_mfa_devices_all(AssignmentStatus, default_config()).
805805

806-
-spec list_virtual_mfa_devices_all(string(), aws_config()) -> {ok, proplist()} | {error, any()}.
806+
-spec list_virtual_mfa_devices_all(undefined | string(), aws_config()) -> {ok, proplist()} | {error, any()}.
807807
list_virtual_mfa_devices_all(AssignmentStatus, #aws_config{} = Config) ->
808808
Params = make_list_virtual_mfa_devices_params(AssignmentStatus, undefined, undefined),
809809
ItemPath = "/ListVirtualMFADevicesResponse/ListVirtualMFADevicesResult/VirtualMFADevices/member",

src/erlcloud_states.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ start_execution(StateMachineArn, Options) ->
539539
start_execution(StateMachineArn, Options, default_config()).
540540

541541
-spec start_execution(StateMachineArn :: binary(),
542-
Options :: list(),
542+
Options :: #{binary() => term()},
543543
Config :: aws_config()) ->
544544
{ok, map()} | {error, any()}.
545545
start_execution(StateMachineArn, Options, Config)
@@ -573,8 +573,8 @@ stop_execution(ExecutionArn, Options) ->
573573
stop_execution(ExecutionArn, Options, default_config()).
574574

575575
-spec stop_execution(ExecutionArn :: binary(),
576-
Options :: list(),
577-
Config :: aws_config()) ->
576+
Options :: #{binary() => term()},
577+
Config :: aws_config()) ->
578578
{ok, map()} | {error, any()}.
579579
stop_execution(ExecutionArn, Options, Config)
580580
when is_binary(ExecutionArn), is_map(Options) ->

0 commit comments

Comments
 (0)