Skip to content

Commit 2f4415b

Browse files
authored
TECH-76: Upgrades to Erlang/OTP 27 (#31)
* TECH-76: Upgrades to Erlang/OTP 27 * Lmao oops, fixes dep. Doesn't seem to get broken anyway * Bumps CI
1 parent 2487b3f commit 2f4415b

15 files changed

+127
-113
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
33
# are the same. See: https://github.com/erlware/relx/pull/902
44
SERVICE_NAME=wapi-pcidss
5-
OTP_VERSION=24.3.4
6-
REBAR_VERSION=3.18
5+
OTP_VERSION=27.1.2
6+
REBAR_VERSION=3.24
77
THRIFT_VERSION=0.14.2.3

.github/workflows/erlang-checks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
thrift-version: ${{ steps.thrift-version.outputs.version }}
1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222
- run: grep -v '^#' .env >> $GITHUB_ENV
2323
- id: otp-version
2424
run: echo "::set-output name=version::$OTP_VERSION"
@@ -30,7 +30,7 @@ jobs:
3030
run:
3131
name: Run checks
3232
needs: setup
33-
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.15
33+
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.18
3434
with:
3535
otp-version: ${{ needs.setup.outputs.otp-version }}
3636
rebar-version: ${{ needs.setup.outputs.rebar-version }}

apps/wapi/src/wapi.app.src

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
public_key,
1010
genlib,
1111
lechiffre,
12+
prometheus,
13+
prometheus_cowboy,
1214
woody,
1315
wapi_woody_client,
1416
scoper,

apps/wapi/src/wapi_crypto.erl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
-module(wapi_crypto).
22

3-
-include_lib("fistful_proto/include/ff_proto_resource_token_thrift.hrl").
3+
-include_lib("fistful_proto/include/fistful_restoken_thrift.hrl").
44

55
-type encrypted_token() :: binary().
66
-type deadline() :: wapi_utils:deadline().
7-
-type resource_token() :: ff_proto_resource_token_thrift:'ResourceToken'().
8-
-type resource_payload() :: ff_proto_resource_token_thrift:'ResourcePayload'().
7+
-type resource_token() :: fistful_restoken_thrift:'ResourceToken'().
8+
-type resource_payload() :: fistful_restoken_thrift:'ResourcePayload'().
99
-type resource() :: {bank_card, bank_card()}.
10-
-type bank_card() :: ff_proto_base_thrift:'BankCard'().
10+
-type bank_card() :: fistful_fistful_base_thrift:'BankCard'().
1111

1212
-export_type([encrypted_token/0]).
1313
-export_type([resource/0]).
@@ -18,7 +18,7 @@
1818
-spec create_resource_token(resource(), deadline()) -> encrypted_token().
1919
create_resource_token(Resource, ValidUntil) ->
2020
ResourceToken = encode_resource_token(Resource, ValidUntil),
21-
ThriftType = {struct, struct, {ff_proto_resource_token_thrift, 'ResourceToken'}},
21+
ThriftType = {struct, struct, {fistful_restoken_thrift, 'ResourceToken'}},
2222
{ok, EncodedToken} = lechiffre:encode(ThriftType, ResourceToken),
2323
TokenVersion = token_version(),
2424
<<TokenVersion/binary, ".", EncodedToken/binary>>.
@@ -45,18 +45,18 @@ token_version() ->
4545
<<"v2">>.
4646

4747
decrypt_token(EncryptedToken) ->
48-
ThriftType = {struct, struct, {ff_proto_resource_token_thrift, 'ResourceToken'}},
48+
ThriftType = {struct, struct, {fistful_restoken_thrift, 'ResourceToken'}},
4949
case lechiffre:decode(ThriftType, EncryptedToken) of
5050
{ok, ResourceToken} ->
51-
Resource = decode_resource_payload(ResourceToken#rst_ResourceToken.payload),
52-
ValidUntil = decode_deadline(ResourceToken#rst_ResourceToken.valid_until),
51+
Resource = decode_resource_payload(ResourceToken#restoken_ResourceToken.payload),
52+
ValidUntil = decode_deadline(ResourceToken#restoken_ResourceToken.valid_until),
5353
{ok, {Resource, ValidUntil}};
5454
{error, _} = Error ->
5555
Error
5656
end.
5757

5858
decrypt_token_v1(EncryptedToken) ->
59-
ThriftType = {struct, struct, {ff_proto_base_thrift, 'BankCard'}},
59+
ThriftType = {struct, struct, {fistful_fistful_base_thrift, 'BankCard'}},
6060
case lechiffre:decode(ThriftType, EncryptedToken) of
6161
{ok, BankCard} ->
6262
{ok, {{bank_card, BankCard}, undefined}};
@@ -72,14 +72,14 @@ encode_deadline(Deadline) ->
7272

7373
-spec encode_resource_token(resource(), deadline()) -> resource_token().
7474
encode_resource_token(Resource, ValidUntil) ->
75-
#rst_ResourceToken{
75+
#restoken_ResourceToken{
7676
payload = encode_resource_payload(Resource),
7777
valid_until = encode_deadline(ValidUntil)
7878
}.
7979

8080
-spec encode_resource_payload(resource()) -> resource_payload().
8181
encode_resource_payload({bank_card, BankCard}) ->
82-
{bank_card_payload, #rst_BankCardPayload{
82+
{bank_card_payload, #restoken_BankCardPayload{
8383
bank_card = BankCard
8484
}}.
8585

@@ -91,4 +91,4 @@ decode_deadline(Deadline) ->
9191

9292
-spec decode_resource_payload(resource_payload()) -> resource().
9393
decode_resource_payload({bank_card_payload, Payload}) ->
94-
{bank_card, Payload#rst_BankCardPayload.bank_card}.
94+
{bank_card, Payload#restoken_BankCardPayload.bank_card}.

apps/wapi/src/wapi_handler.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ process_woody_error(_Source, resource_unavailable, _Details) ->
132132
process_woody_error(_Source, result_unknown, _Details) ->
133133
wapi_handler_utils:reply_error(504).
134134

135-
do_authorize_api_key(SwagContext = #{auth_context := PreAuthContext}, WoodyContext) ->
135+
do_authorize_api_key(#{auth_context := PreAuthContext} = SwagContext, WoodyContext) ->
136136
case wapi_auth:authorize_api_key(PreAuthContext, make_token_context(SwagContext), WoodyContext) of
137137
{ok, AuthContext} ->
138138
SwagContext#{auth_context => AuthContext};

apps/wapi/src/wapi_payres_handler.erl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-module(wapi_payres_handler).
22

3-
-include_lib("fistful_proto/include/ff_proto_base_thrift.hrl").
3+
-include_lib("fistful_proto/include/fistful_fistful_base_thrift.hrl").
44
-include_lib("cds_proto/include/cds_proto_storage_thrift.hrl").
55

66
-include_lib("opentelemetry_api/include/otel_tracer.hrl").
@@ -90,15 +90,15 @@ handle_request(OperationID, Req, SwagContext, Opts) ->
9090
end).
9191

9292
-spec prepare(operation_id(), req_data(), handler_context(), handler_opts()) -> {ok, request_state()} | no_return().
93-
prepare(OperationID = 'StoreBankCard', #{'BankCard' := CardData}, Context, _Opts) ->
93+
prepare('StoreBankCard' = OperationID, #{'BankCard' := CardData}, Context, _Opts) ->
9494
Authorize = mk_auth_function(OperationID, Context),
9595
Process = fun() ->
9696
CVV = maps:get(<<"cvv">>, CardData, undefined),
9797
{BankCard, AuthData} = process_card_data(CardData, CVV, Context),
9898
wapi_handler_utils:reply_ok(201, decode_bank_card(BankCard, AuthData))
9999
end,
100100
{ok, #{authorize => Authorize, process => Process}};
101-
prepare(OperationID = 'GetBankCard', #{'token' := Token}, Context, _Opts) ->
101+
prepare('GetBankCard' = OperationID, #{'token' := Token}, Context, _Opts) ->
102102
Authorize = mk_auth_function(OperationID, Context),
103103
Process = fun() ->
104104
try
@@ -145,8 +145,8 @@ decrypt_token(Token) ->
145145
_ ->
146146
Resource
147147
end,
148-
LastDigits = wapi_utils:get_last_pan_digits(BankCard#'BankCard'.masked_pan),
149-
Bin = BankCard#'BankCard'.bin,
148+
LastDigits = wapi_utils:get_last_pan_digits(BankCard#fistful_base_BankCard.masked_pan),
149+
Bin = BankCard#fistful_base_BankCard.bin,
150150
genlib_map:compact(
151151
#{
152152
<<"token">> => Token,
@@ -278,7 +278,7 @@ to_thrift(card_data, Data) ->
278278
};
279279
to_thrift(bank_card, BankCard) ->
280280
ExpDate = genlib_map:get(exp_date, BankCard),
281-
#'BankCard'{
281+
#fistful_base_BankCard{
282282
token = maps:get(token, BankCard),
283283
bin = maps:get(bin, BankCard),
284284
masked_pan = maps:get(last_digits, BankCard),
@@ -289,7 +289,7 @@ to_thrift(bank_card, BankCard) ->
289289
to_thrift(exp_date, undefined) ->
290290
undefined;
291291
to_thrift(exp_date, {Month, Year}) ->
292-
#'BankCardExpDate'{
292+
#fistful_base_BankCardExpDate{
293293
month = Month,
294294
year = Year
295295
};
@@ -302,7 +302,7 @@ to_thrift(session_data, undefined) ->
302302
to_thrift(payment_system, undefined) ->
303303
undefined;
304304
to_thrift(payment_system, ID) ->
305-
#'PaymentSystemRef'{id = ID}.
305+
#fistful_base_PaymentSystemRef{id = ID}.
306306

307307
decode_bank_card(BankCard, AuthData) ->
308308
#{

apps/wapi/src/wapi_sup.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ get_logic_handler_info() ->
4444
-spec enable_health_logging(erl_health:check()) -> erl_health:check().
4545
enable_health_logging(Check) ->
4646
EvHandler = {erl_health_event_handler, []},
47-
maps:map(fun(_, V = {_, _, _}) -> #{runner => V, event_handler => EvHandler} end, Check).
47+
maps:map(fun(_, {_, _, _} = V) -> #{runner => V, event_handler => EvHandler} end, Check).
4848

4949
-spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}.
5050
get_prometheus_route() ->

apps/wapi/src/wapi_swagger_server.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ mk_operation_id_getter(#{env := Env}) ->
7575
%% cowboy_router:execute/2.
7676
%% NOTE: Be careful when upgrade cowboy in this project
7777
%% because cowboy_router:execute/2 call can change.
78-
get_operation_id(Req = #{host := _Host, path := _Path}, Env) ->
78+
get_operation_id(#{host := _Host, path := _Path} = Req, Env) ->
7979
case cowboy_router:execute(Req, Env) of
8080
{ok, _, #{handler_opts := {_Operations, _LogicHandler, _SwaggerHandlerOpts} = HandlerOpts}} ->
8181
case swag_server_payres_utils:get_operation_id(Req, HandlerOpts) of

apps/wapi/test/wapi_SUITE.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
-include_lib("common_test/include/ct.hrl").
44

5-
-include_lib("fistful_proto/include/ff_proto_base_thrift.hrl").
5+
-include_lib("fistful_proto/include/fistful_fistful_base_thrift.hrl").
66
-include_lib("cds_proto/include/cds_proto_storage_thrift.hrl").
77
-include_lib("binbase_proto/include/binbase_binbase_thrift.hrl").
88
-include_lib("stdlib/include/assert.hrl").
@@ -251,8 +251,8 @@ create_resource_test(C) ->
251251
<<"token">> := ResourceToken
252252
}} = call_store_bank_card(CardNumber, C),
253253
{ok, {{bank_card, BankCard}, _ValidUntil}} = wapi_crypto:decrypt_resource_token(ResourceToken),
254-
?assertEqual(?BIN(CardNumber), BankCard#'BankCard'.bin),
255-
?assertEqual(?LAST_DIGITS(CardNumber), BankCard#'BankCard'.masked_pan).
254+
?assertEqual(?BIN(CardNumber), BankCard#fistful_base_BankCard.bin),
255+
?assertEqual(?LAST_DIGITS(CardNumber), BankCard#fistful_base_BankCard.masked_pan).
256256

257257
-spec valid_until_resource_test(config()) -> test_return().
258258
valid_until_resource_test(C) ->

apps/wapi/test/wapi_ct_helper_bouncer.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-module(wapi_ct_helper_bouncer).
22

3-
-include_lib("common_test/include/ct.hrl").
43
-include_lib("wapi_dummy_data.hrl").
54
-include_lib("wapi_bouncer_data.hrl").
6-
-include_lib("stdlib/include/assert.hrl").
75

86
-export([mock_client/1]).
97
-export([mock_arbiter/2]).
@@ -81,7 +79,7 @@ combine_fragments(Fragments) ->
8179
[Fragment | Rest] = maps:values(Fragments),
8280
lists:foldl(fun combine_fragments/2, Fragment, Rest).
8381

84-
combine_fragments(Fragment1 = #ctx_v1_ContextFragment{}, Fragment2 = #ctx_v1_ContextFragment{}) ->
82+
combine_fragments(#ctx_v1_ContextFragment{} = Fragment1, #ctx_v1_ContextFragment{} = Fragment2) ->
8583
combine_records(Fragment1, Fragment2).
8684

8785
combine_records(Record1, Record2) ->

0 commit comments

Comments
 (0)