@@ -93,32 +93,6 @@ func main() {
93
93
os .Exit (1 )
94
94
}
95
95
96
- if viper .GetBool (config .CreateWebhookCertificateKey ) {
97
- // create webhook server certificate
98
- logrus .Infoln ("Creating self signing certs" )
99
- podNamespace , err := kubeutils .GetCurrentNamespace ()
100
-
101
- if err != nil {
102
- logrus .WithError (err ).Panic ("unable to get pod namespace" )
103
- }
104
-
105
- certBundle , err :=
106
- operatorwebhooks .GenerateSelfSignedCertificate ("otterize-network-mapper-webhook-service" , podNamespace )
107
- if err != nil {
108
- logrus .WithError (err ).Panic ("unable to create self signed certs for webhook" )
109
- }
110
- err = operatorwebhooks .WriteCertToFiles (certBundle )
111
- if err != nil {
112
- logrus .WithError (err ).Panic ("failed writing certs to file system" )
113
- }
114
-
115
- err = operatorwebhooks .UpdateMutationWebHookCA (context .Background (),
116
- "otterize-aws-visibility-mutating-webhook-configuration" , certBundle .CertPem )
117
- if err != nil {
118
- logrus .WithError (err ).Panic ("updating validation webhook certificate failed" )
119
- }
120
- }
121
-
122
96
errgrp .Go (func () error {
123
97
defer errorreporter .AutoNotify ()
124
98
@@ -162,7 +136,9 @@ func main() {
162
136
defer cancelFn ()
163
137
mgr .GetCache ().WaitForCacheSync (initCtx ) // needed to let the manager initialize before used in intentsHolder
164
138
165
- if viper .GetBool (config .EnableAWSVisibilityKeyWebHook ) {
139
+ if viper .GetBool (config .EnableAWSVisibilityWebHookKey ) {
140
+ logrus .Infoln ("Registering AWS visibility mutating webhook" )
141
+
166
142
webhookHandler , err := pod_webhook .NewInjectDNSConfigToPodWebhook (
167
143
mgr .GetClient (),
168
144
admission .NewDecoder (mgr .GetScheme ()),
@@ -178,6 +154,32 @@ func main() {
178
154
Handler : webhookHandler ,
179
155
},
180
156
)
157
+
158
+ if viper .GetBool (config .CreateWebhookCertificateKey ) {
159
+ // create webhook server certificate
160
+ logrus .Infoln ("Creating self signing certs for webhook" )
161
+ podNamespace , err := kubeutils .GetCurrentNamespace ()
162
+
163
+ if err != nil {
164
+ logrus .WithError (err ).Panic ("unable to get pod namespace" )
165
+ }
166
+
167
+ certBundle , err :=
168
+ operatorwebhooks .GenerateSelfSignedCertificate ("otterize-network-mapper-webhook-service" , podNamespace )
169
+ if err != nil {
170
+ logrus .WithError (err ).Panic ("unable to create self signed certs for webhook" )
171
+ }
172
+ err = operatorwebhooks .WriteCertToFiles (certBundle )
173
+ if err != nil {
174
+ logrus .WithError (err ).Panic ("failed writing certs to file system" )
175
+ }
176
+
177
+ err = operatorwebhooks .UpdateMutationWebHookCA (context .Background (),
178
+ "otterize-aws-visibility-mutating-webhook-configuration" , certBundle .CertPem )
179
+ if err != nil {
180
+ logrus .WithError (err ).Panic ("updating validation webhook certificate failed" )
181
+ }
182
+ }
181
183
}
182
184
183
185
intentsHolder := intentsstore .NewIntentsHolder ()
0 commit comments