Skip to content

Commit 32124ef

Browse files
michaelklishinmergify[bot]
authored andcommitted
Naming
(cherry picked from commit 5e9e2f2)
1 parent 8f14169 commit 32124ef

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

deps/rabbit/src/rabbit_vhost_defaults.erl renamed to deps/rabbit/src/rabbit_db_vhost_defaults.erl

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
%% Copyright (c) 2023-2023 VMware, Inc. or its affiliates. All rights reserved.
66
%%
77

8-
-module(rabbit_vhost_defaults).
8+
-module(rabbit_db_vhost_defaults).
99

1010
-export([apply/2]).
1111
-export([list_limits/1, list_operator_policies/1, list_users/1]).
1212

1313
-type definitions() :: [{binary(), term()}].
1414

15-
-record(policy, {
15+
-record(seeding_policy, {
1616
name :: binary(),
1717
queue_pattern = <<".*">> :: binary(),
1818
definition = [] :: definitions()
1919
}).
2020

21-
-type user() :: #{
21+
-type seeded_user_properties() :: #{
2222
name := binary(),
2323
configure := binary(),
2424
read := binary(),
@@ -40,7 +40,7 @@ apply(VHost, ActingUser) ->
4040
end,
4141
lists:foreach(
4242
fun(P) ->
43-
ok = rabbit_policy:set_op(VHost, P#policy.name, P#policy.queue_pattern, P#policy.definition,
43+
ok = rabbit_policy:set_op(VHost, P#seeding_policy.name, P#seeding_policy.queue_pattern, P#seeding_policy.definition,
4444
undefined, undefined, ActingUser),
4545
rabbit_log:info("Applied default operator policy to vhost '~tp': ~tp", [VHost, P])
4646
end,
@@ -80,7 +80,7 @@ list_limits(VHost) ->
8080
end.
8181

8282
%% Operator policies that were configured with a matching vhost pattern.
83-
-spec list_operator_policies(vhost:name()) -> [#policy{}].
83+
-spec list_operator_policies(vhost:name()) -> [#seeding_policy{}].
8484
list_operator_policies(VHost) ->
8585
AllPolicies = application:get_env(rabbit, default_policies, []),
8686
OpPolicies = proplists:get_value(operator, AllPolicies, []),
@@ -92,7 +92,7 @@ list_operator_policies(VHost) ->
9292
QPattern = proplists:get_value(<<"queue_pattern">>, Ss, <<".*">>),
9393
Ss1 = proplists:delete(<<"queue_pattern">>, Ss),
9494
Ss2 = proplists:delete(<<"vhost_pattern">>, Ss1),
95-
{true, #policy{
95+
{true, #seeding_policy{
9696
name = PolicyName,
9797
queue_pattern = QPattern,
9898
definition = underscore_to_dash(Ss2)
@@ -105,7 +105,7 @@ list_operator_policies(VHost) ->
105105
).
106106

107107
%% Users (permissions) that were configured with a matching vhost pattern.
108-
-spec list_users(vhost:name()) -> [user()].
108+
-spec list_users(vhost:name()) -> [seeded_user_properties()].
109109
list_users(VHost) ->
110110
Users = application:get_env(rabbit, default_users, []),
111111
lists:filtermap(
@@ -160,7 +160,7 @@ underscore_to_dash(Props) ->
160160
).
161161

162162
%% Add user iff it doesn't exist & set permissions per vhost.
163-
-spec add_user(rabbit_types:vhost(), user(), rabbit_types:username()) -> ok.
163+
-spec add_user(rabbit_types:vhost(), seeded_user_properties(), rabbit_types:username()) -> ok.
164164
add_user(VHost, #{name := Name, configure := C, write := W, read := R} = User, ActingUser) ->
165165
%% put_user has its own existence check, but it still updates password if the user exists.
166166
%% We want only the newly created users to have password set from the config.

deps/rabbit/src/rabbit_vhost.erl

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ do_add(Name, Metadata, ActingUser) ->
193193
rabbit_log:info("Adding vhost '~ts' (description: '~ts', tags: ~tp)",
194194
[Name, Description, Tags])
195195
end,
196-
DefaultLimits = rabbit_vhost_defaults:list_limits(Name),
196+
DefaultLimits = rabbit_db_vhost_defaults:list_limits(Name),
197197
{NewOrNot, VHost} = rabbit_db_vhost:create_or_get(Name, DefaultLimits, Metadata),
198198
case NewOrNot of
199199
new ->
200200
rabbit_log:info("Inserted a virtual host record ~tp", [VHost]);
201201
existing ->
202202
ok
203203
end,
204-
rabbit_vhost_defaults:apply(Name, ActingUser),
204+
rabbit_db_vhost_defaults:apply(Name, ActingUser),
205205
_ = [begin
206206
Resource = rabbit_misc:r(Name, exchange, ExchangeName),
207207
rabbit_log:debug("Will declare an exchange ~tp", [Resource]),

0 commit comments

Comments
 (0)