@@ -174,7 +174,7 @@ func (m *ODLMOperator) GetCatalogSourceAndChannelFromPackage(ctx context.Context
174
174
continue
175
175
}
176
176
177
- hasCatalogPermission := m .CheckResAuth (ctx , namespace , "operators.coreos.com" , "catalogsources" , "get" )
177
+ hasCatalogPermission := m .CheckResAuth (ctx , pm . Status . CatalogSourceNamespace , "operators.coreos.com" , "catalogsources" , "get" )
178
178
if ! hasCatalogPermission {
179
179
klog .V (2 ).Infof ("No permission to get CatalogSource %s in the namespace %s" , pm .Status .CatalogSource , pm .Status .CatalogSourceNamespace )
180
180
continue
@@ -230,8 +230,8 @@ func (m *ODLMOperator) GetCatalogSourceAndChannelFromPackage(ctx context.Context
230
230
}
231
231
232
232
func (m * ODLMOperator ) CheckResAuth (ctx context.Context , namespace , group , resource , verb string ) bool {
233
- sar := & authorizationv1.SubjectAccessReview {
234
- Spec : authorizationv1.SubjectAccessReviewSpec {
233
+ sar := & authorizationv1.SelfSubjectAccessReview {
234
+ Spec : authorizationv1.SelfSubjectAccessReviewSpec {
235
235
ResourceAttributes : & authorizationv1.ResourceAttributes {
236
236
Namespace : namespace ,
237
237
Group : group ,
@@ -241,14 +241,13 @@ func (m *ODLMOperator) CheckResAuth(ctx context.Context, namespace, group, resou
241
241
},
242
242
}
243
243
if err := m .Create (ctx , sar ); err != nil {
244
+ klog .Errorf ("Failed to check operator permission for Kind %s in namespace %s: %v" , resource , namespace , err )
244
245
return false
245
246
}
246
247
247
- if ! sar .Status .Allowed {
248
- return false
249
- }
248
+ klog .V (2 ).Infof ("Operator %s permission in namespace %s for Kind: %s, Allowed: %t, Denied: %t, Reason: %s" , verb , namespace , resource , sar .Status .Allowed , sar .Status .Denied , sar .Status .Reason )
250
249
251
- return true
250
+ return sar . Status . Allowed
252
251
}
253
252
254
253
func channelCheck (channelName string , channelList []operatorsv1.PackageChannel ) bool {
0 commit comments