1
1
/*
2
- Copyright IBM Corp. 2016 All Rights Reserved.
2
+ Copyright IBM Corp. All Rights Reserved.
3
3
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
4
+ SPDX-License-Identifier: Apache-2.0
15
5
*/
16
6
17
7
package policies
@@ -126,8 +116,9 @@ type policyConfig struct {
126
116
// In general, it should only be referenced as an Impl for the configtx.ConfigManager
127
117
type ManagerImpl struct {
128
118
parent * ManagerImpl
129
- basePath string
130
- fqPrefix string
119
+ basePath string // The group level path
120
+ fqPrefix string // If this manager is treated as the root, the fully qualified prefix for policy names
121
+ fqPath string // The true absolute path, taking parents into consideration
131
122
providers map [int32 ]Provider
132
123
config * policyConfig
133
124
pendingConfig map [interface {}]* policyConfig
@@ -148,6 +139,7 @@ func NewManagerImpl(basePath string, providers map[int32]Provider) *ManagerImpl
148
139
return & ManagerImpl {
149
140
basePath : basePath ,
150
141
fqPrefix : PathSeparator + basePath + PathSeparator ,
142
+ fqPath : PathSeparator + basePath , // Overridden after construction in the sub-manager case
151
143
providers : providers ,
152
144
config : & policyConfig {
153
145
policies : make (map [string ]Policy ),
@@ -223,7 +215,7 @@ func (pm *ManagerImpl) GetPolicy(id string) (Policy, bool) {
223
215
return rejectPolicy (relpath ), false
224
216
}
225
217
if logger .IsEnabledFor (logging .DEBUG ) {
226
- logger .Debugf ("Returning policy %s for evaluation" , relpath )
218
+ logger .Debugf ("Returning policy %s from manager %s for evaluation" , relpath , pm . fqPath )
227
219
}
228
220
return policy , true
229
221
}
@@ -247,6 +239,13 @@ func (pm *ManagerImpl) BeginPolicyProposals(tx interface{}, groups []string) ([]
247
239
for i , group := range groups {
248
240
newManager := NewManagerImpl (group , pm .providers )
249
241
newManager .parent = pm
242
+ mi := newManager
243
+ var fqPath []string
244
+ for mi != nil {
245
+ fqPath = append ([]string {PathSeparator , mi .basePath }, fqPath ... )
246
+ mi = mi .parent
247
+ }
248
+ newManager .fqPath = strings .Join (fqPath , "" )
250
249
pendingConfig .managers [group ] = newManager
251
250
managers [i ] = newManager
252
251
}
0 commit comments