5
5
% % Copyright (c) 2023-2023 VMware, Inc. or its affiliates. All rights reserved.
6
6
% %
7
7
8
- -module (rabbit_vhost_defaults ).
8
+ -module (rabbit_db_vhost_defaults ).
9
9
10
10
-export ([apply /2 ]).
11
11
-export ([list_limits /1 , list_operator_policies /1 , list_users /1 ]).
12
12
13
13
-type definitions () :: [{binary (), term ()}].
14
14
15
- -record (policy , {
15
+ -record (seeding_policy , {
16
16
name :: binary (),
17
17
queue_pattern = <<" .*" >> :: binary (),
18
18
definition = [] :: definitions ()
19
19
}).
20
20
21
- -type user () :: #{
21
+ -type seeded_user_properties () :: #{
22
22
name := binary (),
23
23
configure := binary (),
24
24
read := binary (),
@@ -40,7 +40,7 @@ apply(VHost, ActingUser) ->
40
40
end ,
41
41
lists :foreach (
42
42
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 ,
44
44
undefined , undefined , ActingUser ),
45
45
rabbit_log :info (" Applied default operator policy to vhost '~tp ': ~tp " , [VHost , P ])
46
46
end ,
@@ -80,7 +80,7 @@ list_limits(VHost) ->
80
80
end .
81
81
82
82
% % 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 {}].
84
84
list_operator_policies (VHost ) ->
85
85
AllPolicies = application :get_env (rabbit , default_policies , []),
86
86
OpPolicies = proplists :get_value (operator , AllPolicies , []),
@@ -92,7 +92,7 @@ list_operator_policies(VHost) ->
92
92
QPattern = proplists :get_value (<<" queue_pattern" >>, Ss , <<" .*" >>),
93
93
Ss1 = proplists :delete (<<" queue_pattern" >>, Ss ),
94
94
Ss2 = proplists :delete (<<" vhost_pattern" >>, Ss1 ),
95
- {true , # policy {
95
+ {true , # seeding_policy {
96
96
name = PolicyName ,
97
97
queue_pattern = QPattern ,
98
98
definition = underscore_to_dash (Ss2 )
@@ -105,7 +105,7 @@ list_operator_policies(VHost) ->
105
105
).
106
106
107
107
% % 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 ()].
109
109
list_users (VHost ) ->
110
110
Users = application :get_env (rabbit , default_users , []),
111
111
lists :filtermap (
@@ -160,7 +160,7 @@ underscore_to_dash(Props) ->
160
160
).
161
161
162
162
% % 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 .
164
164
add_user (VHost , #{name := Name , configure := C , write := W , read := R } = User , ActingUser ) ->
165
165
% % put_user has its own existence check, but it still updates password if the user exists.
166
166
% % We want only the newly created users to have password set from the config.
0 commit comments