Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
image: erlang:${{matrix.otp_vsn}}
strategy:
matrix:
otp_vsn: [19.3, 20.3, 21.3, 22.3, 23.3, 24.0]
otp_vsn: [24, 25, 26, 27]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: export
- run: make rebar3-install
- run: make warnings
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all get-deps clean compile run eunit check check-eunit doc hex-publish rebar3-install
.PHONY: all get-deps clean compile run eunit check doc hex-publish rebar3-install

REBAR=$(shell which rebar3 || echo ./rebar3)

Expand Down Expand Up @@ -28,14 +28,8 @@ warnings:
eunit:
@ERL_FLAGS="-config $(PWD)/eunit" $(REBAR) eunit

.dialyzer_plt:
dialyzer --build_plt -r _build/default \
--apps erts kernel stdlib inets crypto public_key ssl xmerl \
--fullpath \
--output_plt .dialyzer_plt

check: .dialyzer_plt
@$(REBAR) as test dialyzer
check:
@$(REBAR) as dialyzer do dialyzer --update-plt

doc:
@$(REBAR) edoc
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ At the moment we support the following OTP releases:
- 20.3
- 21.3
- 22.3

It might still work on 17+ (primarily due to Erlang maps) but we do not
guarantee that.
- 23.3
- 24.3
- 25.3
- 26.2
- 27.1

This list is determined by ensuring eunit tests and dialyzer checks succeed for these versions, but not all of these
versions are in active use by library authors. Please report any issues discovered in actual use.

The Github Actions test runners only support OTP 24+ due to runtime issues, but OTP 19-23 were tested locally with unmodified,
official [Erlang docker images](https://hub.docker.com/_/erlang). Dialyzer checks run against the latest hex-published hackney
for OTP 24+, but a previous versions of hackney (1.15.0) and its dependency parse_trans (3.2.0) were used to do dialyzer checks
for OTP 19-23 due to newer versions of parse_trans requiring OTP 21+.

## Getting started

Expand Down
2 changes: 1 addition & 1 deletion include/erlcloud_xmerl.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

-include_lib("xmerl/include/xmerl.hrl").

-type(xmerl_xpath_doc_nodes() :: #xmlElement{} | #xmlAttribute{} | #xmlText{} | #xmlPI{} | #xmlComment{} | #xmlNsNode{}).
-type(xmerl_xpath_doc_nodes() :: #xmlElement{} | #xmlAttribute{} | #xmlText{} | #xmlPI{} | #xmlComment{} | #xmlNsNode{} | #xmlObj{}).
-type(xmerl_xpath_node_entity() :: #xmlDocument{} | xmerl_xpath_doc_nodes()).
-type(xmerl_xpath_doc_entity() :: #xmlDocument{} | [xmerl_xpath_doc_nodes()]).

Expand Down
15 changes: 11 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{deps, [
{jsx, "2.11.0"},
{lhttpc, "1.6.2"},
{lhttpc, "1.7.1"},
{eini, "1.2.9"},
{base16, "1.0.0"}
]}.
Expand All @@ -32,10 +32,17 @@


{profiles, [
{test, [{deps, [{meck, "0.9.0"}]}, {erl_opts, [warnings_as_errors]}]}
,{warnings, [{erl_opts, [warnings_as_errors]}]}
{dialyzer, [{deps, [hackney]}, {erl_opts, [warnings_as_errors]}]},
{test, [{deps, [{meck, "0.9.0"}]}, {erl_opts, [warnings_as_errors]}]},
{warnings, [{erl_opts, [warnings_as_errors]}]}
]}.

{post_hooks, [{clean, "rm -f .dialyzer_plt"}]}.
{post_hooks, [{clean, "rm -rf .dialyzer_plt"}]}.

{pre_hooks, [{clean, "rm -rf erl_crash.dump *.log"}]}.

{dialyzer, [
{plt_location, ".dialyzer_plt"},
{plt_apps, all_deps},
{plt_extra_apps, [hackney]}
]}.
11 changes: 8 additions & 3 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{"1.1.0",
{"1.2.0",
[{<<"base16">>,{pkg,<<"base16">>,<<"1.0.0">>},0},
{<<"eini">>,{pkg,<<"eini">>,<<"1.2.9">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.11.0">>},0},
{<<"lhttpc">>,{pkg,<<"lhttpc">>,<<"1.6.2">>},0}]}.
{<<"lhttpc">>,{pkg,<<"lhttpc">>,<<"1.7.1">>},0}]}.
[
{pkg_hash,[
{<<"base16">>, <<"283644E2B21BD5915ACB7178BED7851FB07C6E5749B8FAD68A53C501092176D9">>},
{<<"eini">>, <<"FCC3CBD49BBDD9A1D9735C7365DAFFCD84481CCE81E6CB80537883AA44AC4895">>},
{<<"jsx">>, <<"08154624050333919B4AC1B789667D5F4DB166DC50E190C4D778D1587F102EE0">>},
{<<"lhttpc">>, <<"044F16F0018C7AA7E945E9E9406C7F6035E0B8BC08BF77B00C78CE260E1071E3">>}]}
{<<"lhttpc">>, <<"8522AF9877765C33318A3AE486BE69BC165E835D05C3334A8166FD7B318D446B">>}]},
{pkg_hash_ext,[
{<<"base16">>, <<"02AFD0827E61A7B07093873E063575CA3A2B07520567C7F8CEC7C5D42F052D76">>},
{<<"eini">>, <<"DA64AE8DB7C2F502E6F20CDF44CD3D9BE364412B87FF49FEBF282540F673DFCB">>},
{<<"jsx">>, <<"EED26A0D04D217F9EECEFFFB89714452556CF90EB38F290A27A4D45B9988F8C0">>},
{<<"lhttpc">>, <<"154EEB27692482B52BE86406DCD1D18A2405CAFCE0E8DAA4A1A7BFA7FE295896">>}]}
].
6 changes: 3 additions & 3 deletions src/erlcloud_cloudfront.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

-define(MAX_RESULTS, 100).

-spec extract_distribution_summary(Node :: list()) -> proplist().
-spec extract_distribution_summary(Node :: xmerl_xpath_doc_nodes()) -> proplist().
extract_distribution_summary(Node) ->
erlcloud_xml:decode(
[
Expand Down Expand Up @@ -58,7 +58,7 @@ extract_distribution(Node) ->
], Node) ++ extract_distribution_config(hd(xmerl_xpath:string("DistributionConfig", Node))).


-spec extract_distribution_config(Node :: list()) -> proplist().
-spec extract_distribution_config(Node :: xmerl_xpath_doc_nodes()) -> proplist().
extract_distribution_config(Node) ->
erlcloud_xml:decode(
[
Expand All @@ -79,7 +79,7 @@ extract_distribution_config(Node) ->
], Node).


-spec extract_cache_behavior(Node :: list()) -> proplist().
-spec extract_cache_behavior(Node :: xmerl_xpath_doc_nodes()) -> proplist().
extract_cache_behavior(Node) ->
erlcloud_xml:decode(
[
Expand Down
24 changes: 12 additions & 12 deletions src/erlcloud_cognito_user_pools.erl
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ admin_get_user(UserName, UserPoolId, Config) ->
admin_create_user(UserName, UserPoolId) ->
admin_create_user(UserName, UserPoolId, #{}).

-spec admin_create_user(binary(), binary(), maps:maps()) ->
-spec admin_create_user(binary(), binary(), map()) ->
{ok, map()} | {error, any()}.
admin_create_user(UserName, UserPoolId, OptionalArgs) ->
Config = erlcloud_aws:default_config(),
admin_create_user(UserName, UserPoolId, OptionalArgs, Config).

-spec admin_create_user(binary(), binary(), maps:maps(), aws_config()) ->
-spec admin_create_user(binary(), binary(), map(), aws_config()) ->
{ok, map()} | {error, any()}.
admin_create_user(UserName, UserPoolId, OptionalArgs, Config) ->
Body = OptionalArgs#{
Expand Down Expand Up @@ -661,13 +661,13 @@ admin_forget_device(UserPoolId, Username, DeviceKey, Config) ->
admin_confirm_signup(UserPoolId, Username) ->
admin_confirm_signup(UserPoolId, Username, #{}).

-spec admin_confirm_signup(binary(), binary(), maps:map()) ->
-spec admin_confirm_signup(binary(), binary(), map()) ->
{ok, map()} | {error, any()}.
admin_confirm_signup(UserPoolId, Username, ClientMetadata) ->
Config = erlcloud_aws:default_config(),
admin_confirm_signup(UserPoolId, Username, ClientMetadata, Config).

-spec admin_confirm_signup(binary(), binary(), maps:map(), aws_config()) ->
-spec admin_confirm_signup(binary(), binary(), map(), aws_config()) ->
{ok, map()} | {error, any()}.
admin_confirm_signup(UserPoolId, Username, ClientMetadata, Config) ->
Body = #{
Expand All @@ -677,21 +677,21 @@ admin_confirm_signup(UserPoolId, Username, ClientMetadata, Config) ->
},
request(Config, "AdminConfirmSignUp", Body).

-spec admin_initiate_auth(binary(), binary(), binary(), maps:map()) ->
-spec admin_initiate_auth(binary(), binary(), binary(), map()) ->
{ok, map()} | {error, any()}.
admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams) ->
Cfg = erlcloud_aws:default_config(),
admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams, Cfg).

-spec admin_initiate_auth(binary(), binary(), binary(),
maps:map(), aws_config()) ->
map(), aws_config()) ->
{ok, map()} | {error, any()}.
admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams, Cfg) ->
admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams,
#{}, #{}, #{}, Cfg).

-spec admin_initiate_auth(binary(), binary(), binary(), maps:map(),
maps:map(), maps:map(), maps:map(), aws_config()) ->
-spec admin_initiate_auth(binary(), binary(), binary(), map(),
map(), map(), map(), aws_config()) ->
{ok, map()} | {error, any()}.
admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams,
AnalyticsMeta, ClientMeta, ContextData, Cfg) ->
Expand All @@ -708,23 +708,23 @@ admin_initiate_auth(PoolId, ClientId, AuthFlow, AuthParams,
},
request(Cfg, "AdminInitiateAuth", make_request_body(Mandatory, Optional)).

-spec respond_to_auth_challenge(binary(), binary(), maps:map(), binary()) ->
-spec respond_to_auth_challenge(binary(), binary(), map(), binary()) ->
{ok, map()} | {error, any()}.
respond_to_auth_challenge(ClientId, ChallengeName, ChallengeResponses, Session) ->
Cfg = erlcloud_aws:default_config(),
respond_to_auth_challenge(ClientId, ChallengeName, ChallengeResponses,
Session, Cfg).

-spec respond_to_auth_challenge(binary(), binary(), maps:map(), binary(),
-spec respond_to_auth_challenge(binary(), binary(), map(), binary(),
aws_config()) ->
{ok, map()} | {error, any()}.
respond_to_auth_challenge(ClientId, ChallengeName, ChallengeResponses,
Session, Cfg) ->
respond_to_auth_challenge(ClientId, ChallengeName, ChallengeResponses,
Session, #{}, #{}, #{}, Cfg).

-spec respond_to_auth_challenge(binary(), binary(), maps:map(), binary(),
maps:map(), maps:map(), maps:map(),
-spec respond_to_auth_challenge(binary(), binary(), map(), binary(),
map(), map(), map(),
aws_config()) ->
{ok, map()} | {error, any()}.
respond_to_auth_challenge(ClientId, ChallengeName, ChallengeResponses,
Expand Down
4 changes: 4 additions & 0 deletions src/erlcloud_ec2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ bundle_instance(InstanceID, Bucket, Prefix, AccessKeyID, UploadPolicy,
Error
end.

-spec extract_bundle_task(Nodes :: [xmerl_xpath_doc_nodes()]) -> proplist();
(Node :: xmerl_xpath_doc_nodes()) -> proplist().
extract_bundle_task([Node]) ->
extract_bundle_task(Node);
extract_bundle_task(Node) ->
[
{instance_id, get_text("instanceId", Node)},
{bundle_id, get_text("bundleId", Node)},
Expand Down
7 changes: 4 additions & 3 deletions src/erlcloud_elb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

-include("erlcloud.hrl").
-include("erlcloud_aws.hrl").
-include("erlcloud_xmerl.hrl").

-define(API_VERSION, "2012-06-01").

Expand Down Expand Up @@ -471,11 +472,11 @@ create_load_balancer_policy(LB, PolicyName, PolicyTypeName, AttrList, Config)
ok.


-spec describe_load_balancer_attributes(string()) -> proplist().
-spec describe_load_balancer_attributes(string()) -> proplist() | no_return().
describe_load_balancer_attributes(Name) ->
describe_load_balancer_attributes(Name, default_config()).

-spec describe_load_balancer_attributes(string(), aws_config()) -> proplist().
-spec describe_load_balancer_attributes(string(), aws_config()) -> proplist() | no_return().
describe_load_balancer_attributes(Name, Config) ->
Node = elb_request(Config,
"DescribeLoadBalancerAttributes",
Expand All @@ -486,7 +487,7 @@ describe_load_balancer_attributes(Name, Config) ->
%%%===================================================================
%%% Internal functions
%%%===================================================================
-spec extract_elb_attribs(proplist()) -> proplist().
-spec extract_elb_attribs(xmerl_xpath_doc_nodes()) -> proplist() | no_return().
extract_elb_attribs(Node) ->
RootPath = "DescribeLoadBalancerAttributesResult/LoadBalancerAttributes",
erlcloud_xml:decode(
Expand Down
8 changes: 4 additions & 4 deletions src/erlcloud_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,18 @@ next_token(Path, XML) ->
ok
end.

-spec filter_undef(proplists:proplist() | maps:map()) ->
proplists:proplist() | maps:map().
-spec filter_undef(proplists:proplist() | map()) ->
proplists:proplist() | map().
filter_undef(List) when is_list(List) ->
lists:filter(fun({_Name, Value}) -> Value =/= undefined end, List);
filter_undef(Map) when is_map(Map) ->
maps:filter(fun(_Key, Value) -> Value =/= undefined end, Map).

-spec filter_empty_map(maps:map()) -> maps:map().
-spec filter_empty_map(map()) -> map().
filter_empty_map(Map) when is_map(Map) ->
maps:filter(fun(_Key, Value) -> Value =/= #{} end, Map).

-spec filter_empty_list(maps:map()) -> maps:map().
-spec filter_empty_list(map()) -> map().
filter_empty_list(Map) when is_map(Map) ->
maps:filter(fun(_Key, Value) -> Value =/= [] end, Map).

Expand Down
8 changes: 4 additions & 4 deletions test/erlcloud_cognito_user_pools_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ test_list_users() ->
do_test(Request, Expected, TestFun).

test_list_all_users() ->
Mocked1 = ?LIST_USERS_RESP#{<<"PaginationToken">> => "1"},
Mocked1 = maps:put(<<"PaginationToken">>, "1", ?LIST_USERS_RESP),
Mocked2 = #{<<"Users">> => [
#{
<<"Attributes">> =>
Expand Down Expand Up @@ -858,7 +858,7 @@ test_list_user_pool_clients() ->
do_test(Request, Expected, TestFun).

test_list_all_user_pool_clients() ->
Mocked1 = ?LIST_USER_POOL_CLIENTS#{<<"NextToken">> => <<"next">>},
Mocked1 = maps:put(<<"NextToken">>, <<"next">>, ?LIST_USER_POOL_CLIENTS),
Mocked2 = ?LIST_USER_POOL_CLIENTS,
meck:sequence(?EHTTPC, request, 6, [{ok, {{200, "OK"}, [], jsx:encode(Mocked1)}},
{ok, {{200, "OK"}, [], jsx:encode(Mocked2)}}]),
Expand All @@ -877,9 +877,9 @@ test_admin_list_devices() ->
do_test(Request, Expected, TestFun).

test_list_all_devices() ->
Mocked1 = ?ADMIN_LIST_DEVICE#{<<"PaginationToken">> => <<"next page">>},
Mocked1 = maps:put(<<"PaginationToken">>, <<"next page">>, ?ADMIN_LIST_DEVICE),
Devices = hd(maps:get(<<"Devices">>, ?ADMIN_LIST_DEVICE)),
Mocked2 = ?ADMIN_LIST_DEVICE#{<<"Devices">> => [Devices#{<<"DeviceKey">> => <<"testKey2">>}]},
Mocked2 = maps:put(<<"Devices">>, [Devices#{<<"DeviceKey">> => <<"testKey2">>}], ?ADMIN_LIST_DEVICE),
meck:sequence(?EHTTPC, request, 6, [{ok, {{200, "OK"}, [], jsx:encode(Mocked1)}},
{ok, {{200, "OK"}, [], jsx:encode(Mocked2)}}]),
Expected = {ok, ?LIST_ALL_DEVICES},
Expand Down
Loading