4
4
"context"
5
5
kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1"
6
6
kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
7
- "github.com/kuadrant/kuadrant-operator/pkg/authorino"
8
7
"github.com/kuadrant/kuadrant-operator/pkg/istio"
9
- "github.com/kuadrant/kuadrant-operator/pkg/limitador"
10
8
"github.com/kuadrant/kuadrant-operator/pkg/log"
11
9
"github.com/kuadrant/kuadrant-operator/pkg/reconcilers"
12
10
"github.com/kuadrant/policy-machinery/controller"
@@ -19,7 +17,6 @@ import (
19
17
istiosecurity "istio.io/client-go/pkg/apis/security/v1"
20
18
v12 "k8s.io/api/apps/v1"
21
19
apiErrors "k8s.io/apimachinery/pkg/api/errors"
22
- "k8s.io/apimachinery/pkg/api/meta"
23
20
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
21
"k8s.io/client-go/dynamic"
25
22
"k8s.io/utils/ptr"
@@ -37,14 +34,12 @@ func (pa *PeerAuthentication) GetLocator() string {
37
34
type MTLSReconciler struct {
38
35
* reconcilers.BaseReconciler
39
36
40
- Client * dynamic.DynamicClient
41
- restMapper meta.RESTMapper
37
+ Client * dynamic.DynamicClient
42
38
}
43
39
44
- func NewMTLSReconciler (mgr controllerruntime.Manager , client * dynamic.DynamicClient , rm meta. RESTMapper ) * MTLSReconciler {
40
+ func NewMTLSReconciler (mgr controllerruntime.Manager , client * dynamic.DynamicClient ) * MTLSReconciler {
45
41
return & MTLSReconciler {
46
- Client : client ,
47
- restMapper : rm ,
42
+ Client : client ,
48
43
BaseReconciler : reconcilers .NewBaseReconciler (
49
44
mgr .GetClient (),
50
45
mgr .GetScheme (),
@@ -123,57 +118,43 @@ outer:
123
118
return nil
124
119
}
125
120
126
- installed , err := authorino .IsAuthorinoOperatorInstalled (r .restMapper , logger )
127
- if err != nil || ! installed {
128
- logger .Info ("authorino is not installed" )
129
- return err
130
- }
131
- if installed {
132
- // find an authorino object, then find and update the associated deployment
133
- aobjs := lo .FilterMap (topology .Objects ().Objects ().Items (), func (item machinery.Object , _ int ) (machinery.Object , bool ) {
134
- if item .GroupVersionKind ().Kind == kuadrantv1beta1 .AuthorinoGroupKind .Kind {
135
- return item , true
136
- }
137
- return nil , false
138
- })
139
- // add label to authorino deployment {"sidecar.istio.io/inject":"true"}}}}}
140
- deployment := & v12.Deployment {
141
- ObjectMeta : metav1.ObjectMeta {
142
- // TODO can't be hardcoded, this is just one example
143
- Name : "authorino" ,
144
- Namespace : aobjs [0 ].GetNamespace (),
145
- },
121
+ // find an authorino object, then find and update the associated deployment
122
+ aobjs := lo .FilterMap (topology .Objects ().Objects ().Items (), func (item machinery.Object , _ int ) (machinery.Object , bool ) {
123
+ if item .GroupVersionKind ().Kind == kuadrantv1beta1 .AuthorinoGroupKind .Kind {
124
+ return item , true
146
125
}
147
- deploymentMutators := make ([]reconcilers.DeploymentMutateFn , 0 )
148
- deploymentMutators = append (deploymentMutators , reconcilers .DeploymentTemplateLabelIstioInjectMutator )
149
- err = r .ReconcileResource (eventCtx , & v12.Deployment {}, deployment , reconcilers .DeploymentMutator (deploymentMutators ... ))
126
+ return nil , false
127
+ })
128
+ // add label to authorino deployment {"sidecar.istio.io/inject":"true"}}}}}
129
+ aDeployment := & v12.Deployment {
130
+ ObjectMeta : metav1.ObjectMeta {
131
+ // TODO can't be hardcoded, this is just one example
132
+ Name : "authorino" ,
133
+ Namespace : aobjs [0 ].GetNamespace (),
134
+ },
150
135
}
136
+ aDeploymentMutators := make ([]reconcilers.DeploymentMutateFn , 0 )
137
+ aDeploymentMutators = append (aDeploymentMutators , reconcilers .DeploymentTemplateLabelIstioInjectMutator )
138
+ err := r .ReconcileResource (eventCtx , & v12.Deployment {}, aDeployment , reconcilers .DeploymentMutator (aDeploymentMutators ... ))
151
139
152
- installed , err = limitador .IsLimitadorOperatorInstalled (r .restMapper , logger )
153
- if err != nil || ! installed {
154
- logger .Info ("limitador is not installed" )
155
- return err
156
- }
157
- if installed {
158
- // find a limitador object, then find and update the associated deployment
159
- lobjs := lo .FilterMap (topology .Objects ().Objects ().Items (), func (item machinery.Object , _ int ) (machinery.Object , bool ) {
160
- if item .GroupVersionKind ().Kind == kuadrantv1beta1 .LimitadorGroupKind .Kind {
161
- return item , true
162
- }
163
- return nil , false
164
- })
165
- // add label to limitador deployment {"sidecar.istio.io/inject":"true"}}}}}
166
- deployment := & v12.Deployment {
167
- ObjectMeta : metav1.ObjectMeta {
168
- // TODO can't be hardcoded, this is just one example
169
- Name : "limitador-limitador" ,
170
- Namespace : lobjs [0 ].GetNamespace (),
171
- },
140
+ // find a limitador object, then find and update the associated deployment
141
+ lobjs := lo .FilterMap (topology .Objects ().Objects ().Items (), func (item machinery.Object , _ int ) (machinery.Object , bool ) {
142
+ if item .GroupVersionKind ().Kind == kuadrantv1beta1 .LimitadorGroupKind .Kind {
143
+ return item , true
172
144
}
173
- deploymentMutators := make ([]reconcilers.DeploymentMutateFn , 0 )
174
- deploymentMutators = append (deploymentMutators , reconcilers .DeploymentTemplateLabelIstioInjectMutator )
175
- err = r .ReconcileResource (eventCtx , & v12.Deployment {}, deployment , reconcilers .DeploymentMutator (deploymentMutators ... ))
145
+ return nil , false
146
+ })
147
+ // add label to limitador deployment {"sidecar.istio.io/inject":"true"}}}}}
148
+ lDeployment := & v12.Deployment {
149
+ ObjectMeta : metav1.ObjectMeta {
150
+ // TODO can't be hardcoded, this is just one example
151
+ Name : "limitador-limitador" ,
152
+ Namespace : lobjs [0 ].GetNamespace (),
153
+ },
176
154
}
155
+ lDeploymentMutators := make ([]reconcilers.DeploymentMutateFn , 0 )
156
+ lDeploymentMutators = append (lDeploymentMutators , reconcilers .DeploymentTemplateLabelIstioInjectMutator )
157
+ err = r .ReconcileResource (eventCtx , & v12.Deployment {}, lDeployment , reconcilers .DeploymentMutator (lDeploymentMutators ... ))
177
158
178
159
valueMap := map [string ]interface {}{
179
160
"transport_socket" : map [string ]interface {}{
0 commit comments