@@ -13,7 +13,7 @@ import (
13
13
14
14
//go:generate mockgen -source=authorization.go -package=ocm -destination=mock_authorization.go
15
15
type OCMAuthorization interface {
16
- ResourceReview (ctx context.Context , username , action , resourceType string ) (allowed []string , err error )
16
+ ResourceReview (ctx context.Context , username , action , resourceType string ) (clusterIds [] string , clusterUuids []string , err error )
17
17
AccessReview (ctx context.Context , username , action , subscriptionId , resourceType string ) (allowed bool , err error )
18
18
CapabilityReview (ctx context.Context , username , capabilityName , capabilityType string ) (allowed bool , err error )
19
19
}
@@ -22,7 +22,7 @@ type authorization struct {
22
22
client * Client
23
23
}
24
24
25
- func (a authorization ) ResourceReview (ctx context.Context , username , action , resourceType string ) (allowed []string , err error ) {
25
+ func (a authorization ) ResourceReview (ctx context.Context , username , action , resourceType string ) (clusterIds [] string , clusterUuids []string , err error ) {
26
26
defer commonutils .MeasureOperation ("OCM-ResourceReview" , a .client .log , a .client .metricsApi )()
27
27
resourceReview := a .client .connection .Authorizations ().V1 ().ResourceReview ()
28
28
@@ -33,7 +33,7 @@ func (a authorization) ResourceReview(ctx context.Context, username, action, res
33
33
34
34
request , err := requestBuilder .Build ()
35
35
if err != nil {
36
- return nil , err
36
+ return nil , nil , err
37
37
}
38
38
39
39
postResp , err := resourceReview .Post ().
@@ -43,25 +43,30 @@ func (a authorization) ResourceReview(ctx context.Context, username, action, res
43
43
if postResp != nil {
44
44
a .client .logger .Error (context .Background (), "Fail to send ResourceReview. Response: %v" , postResp )
45
45
if postResp .Status () >= 400 && postResp .Status () < 500 {
46
- return nil , common .NewInfraError (http .StatusUnauthorized , err )
46
+ return nil , nil , common .NewInfraError (http .StatusUnauthorized , err )
47
47
}
48
48
if postResp .Status () >= 500 {
49
- return nil , common .NewApiError (http .StatusServiceUnavailable , err )
49
+ return nil , nil , common .NewApiError (http .StatusServiceUnavailable , err )
50
50
}
51
51
}
52
- return nil , common .NewApiError (http .StatusServiceUnavailable , err )
52
+ return nil , nil , common .NewApiError (http .StatusServiceUnavailable , err )
53
53
}
54
54
55
55
response , ok := postResp .GetReview ()
56
56
if ! ok {
57
- return nil , errors .Errorf ("Empty response from authorization post request" )
57
+ return nil , nil , errors .Errorf ("Empty response from authorization post request" )
58
58
}
59
59
60
- clusterIDs , ok : = response .GetClusterIDs ()
60
+ clusterIds , ok = response .GetClusterIDs ()
61
61
if ! ok {
62
- return nil , errors .Errorf ("Failed to get cluster IDs from the response" )
62
+ return nil , nil , errors .Errorf ("Failed to get cluster IDs from the response" )
63
63
}
64
- return clusterIDs , nil
64
+
65
+ clusterUuids , ok = response .GetClusterUUIDs ()
66
+ if ! ok {
67
+ return nil , nil , errors .Errorf ("Failed to get cluster UUIDs from the response" )
68
+ }
69
+ return clusterIds , clusterUuids , nil
65
70
}
66
71
67
72
func (a authorization ) AccessReview (ctx context.Context , username , action , subscriptionId , resourceType string ) (allowed bool , err error ) {
0 commit comments