@@ -130,8 +130,8 @@ func main() {
130
130
131
131
mustProcessGlobalConfiguration (ctx )
132
132
133
- cfgParams := configs .NewDefaultConfigParams (* nginxPlus )
134
- cfgParams = processConfigMaps (ctx , kubeClient , cfgParams , nginxManager , templateExecutor )
133
+ cfgParams := configs .NewDefaultConfigParams (ctx , * nginxPlus )
134
+ cfgParams = processConfigMaps (kubeClient , cfgParams , nginxManager , templateExecutor )
135
135
136
136
staticCfgParams := & configs.StaticConfigParams {
137
137
DisableIPV6 : * disableIPV6 ,
@@ -162,7 +162,7 @@ func main() {
162
162
AppProtectBundlePath : appProtectBundlePath ,
163
163
}
164
164
165
- mustProcessNginxConfig (ctx , staticCfgParams , cfgParams , templateExecutor , nginxManager )
165
+ mustProcessNginxConfig (staticCfgParams , cfgParams , templateExecutor , nginxManager )
166
166
167
167
if * enableTLSPassthrough {
168
168
var emptyFile []byte
@@ -202,7 +202,7 @@ func main() {
202
202
)
203
203
204
204
if * enableServiceInsight {
205
- createHealthProbeEndpoint (ctx , kubeClient , plusClient , cnf )
205
+ createHealthProbeEndpoint (kubeClient , plusClient , cnf )
206
206
}
207
207
208
208
lbcInput := k8s.NewLoadBalancerControllerInput {
@@ -266,7 +266,7 @@ func main() {
266
266
}()
267
267
}
268
268
269
- go handleTermination (ctx , lbc , nginxManager , syslogListener , process )
269
+ go handleTermination (lbc , nginxManager , syslogListener , process )
270
270
271
271
lbc .Run ()
272
272
@@ -606,8 +606,8 @@ func createGlobalConfigurationValidator() *cr_validation.GlobalConfigurationVali
606
606
607
607
// mustProcessNginxConfig calls internally os.Exit
608
608
// if can't generate a valid NGINX config.
609
- func mustProcessNginxConfig (ctx context. Context , staticCfgParams * configs.StaticConfigParams , cfgParams * configs.ConfigParams , templateExecutor * version1.TemplateExecutor , nginxManager nginx.Manager ) {
610
- l := nl .LoggerFromContext (ctx )
609
+ func mustProcessNginxConfig (staticCfgParams * configs.StaticConfigParams , cfgParams * configs.ConfigParams , templateExecutor * version1.TemplateExecutor , nginxManager nginx.Manager ) {
610
+ l := nl .LoggerFromContext (cfgParams . Context )
611
611
ngxConfig := configs .GenerateNginxMainConfig (staticCfgParams , cfgParams )
612
612
content , err := templateExecutor .ExecuteMainConfigTemplate (ngxConfig )
613
613
if err != nil {
@@ -655,24 +655,23 @@ func getAndValidateSecret(kubeClient *kubernetes.Clientset, secretNsName string)
655
655
return secret , nil
656
656
}
657
657
658
- func handleTermination (ctx context.Context , lbc * k8s.LoadBalancerController , nginxManager nginx.Manager , listener metrics.SyslogListener , cpcfg childProcesses ) {
659
- l := nl .LoggerFromContext (ctx )
658
+ func handleTermination (lbc * k8s.LoadBalancerController , nginxManager nginx.Manager , listener metrics.SyslogListener , cpcfg childProcesses ) {
660
659
signalChan := make (chan os.Signal , 1 )
661
660
signal .Notify (signalChan , syscall .SIGTERM )
662
661
663
662
select {
664
663
case err := <- cpcfg .nginxDone :
665
664
if err != nil {
666
- nl .Fatalf (l , "nginx command exited unexpectedly with status: %v" , err )
665
+ nl .Fatalf (lbc . Logger , "nginx command exited unexpectedly with status: %v" , err )
667
666
} else {
668
- nl .Info (l , "nginx command exited successfully" )
667
+ nl .Info (lbc . Logger , "nginx command exited successfully" )
669
668
}
670
669
case err := <- cpcfg .aPPluginDone :
671
- nl .Fatalf (l , "AppProtectPlugin command exited unexpectedly with status: %v" , err )
670
+ nl .Fatalf (lbc . Logger , "AppProtectPlugin command exited unexpectedly with status: %v" , err )
672
671
case err := <- cpcfg .aPDosDone :
673
- nl .Fatalf (l , "AppProtectDosAgent command exited unexpectedly with status: %v" , err )
672
+ nl .Fatalf (lbc . Logger , "AppProtectDosAgent command exited unexpectedly with status: %v" , err )
674
673
case <- signalChan :
675
- nl .Info (l , "Received SIGTERM, shutting down" )
674
+ nl .Info (lbc . Logger , "Received SIGTERM, shutting down" )
676
675
lbc .Stop ()
677
676
nginxManager .Quit ()
678
677
<- cpcfg .nginxDone
@@ -686,7 +685,7 @@ func handleTermination(ctx context.Context, lbc *k8s.LoadBalancerController, ngi
686
685
}
687
686
listener .Stop ()
688
687
}
689
- nl .Info (l , "Exiting successfully" )
688
+ nl .Info (lbc . Logger , "Exiting successfully" )
690
689
os .Exit (0 )
691
690
}
692
691
@@ -801,8 +800,8 @@ func createPlusAndLatencyCollectors(
801
800
return plusCollector , syslogListener , lc
802
801
}
803
802
804
- func createHealthProbeEndpoint (ctx context. Context , kubeClient * kubernetes.Clientset , plusClient * client.NginxClient , cnf * configs.Configurator ) {
805
- l := nl .LoggerFromContext (ctx )
803
+ func createHealthProbeEndpoint (kubeClient * kubernetes.Clientset , plusClient * client.NginxClient , cnf * configs.Configurator ) {
804
+ l := nl .LoggerFromContext (cnf . CfgParams . Context )
806
805
if ! * enableServiceInsight {
807
806
return
808
807
}
@@ -834,8 +833,8 @@ func mustProcessGlobalConfiguration(ctx context.Context) {
834
833
}
835
834
}
836
835
837
- func processConfigMaps (ctx context. Context , kubeClient * kubernetes.Clientset , cfgParams * configs.ConfigParams , nginxManager nginx.Manager , templateExecutor * version1.TemplateExecutor ) * configs.ConfigParams {
838
- l := nl .LoggerFromContext (ctx )
836
+ func processConfigMaps (kubeClient * kubernetes.Clientset , cfgParams * configs.ConfigParams , nginxManager nginx.Manager , templateExecutor * version1.TemplateExecutor ) * configs.ConfigParams {
837
+ l := nl .LoggerFromContext (cfgParams . Context )
839
838
if * nginxConfigMaps != "" {
840
839
ns , name , err := k8s .ParseNamespaceName (* nginxConfigMaps )
841
840
if err != nil {
@@ -845,7 +844,7 @@ func processConfigMaps(ctx context.Context, kubeClient *kubernetes.Clientset, cf
845
844
if err != nil {
846
845
nl .Fatalf (l , "Error when getting %v: %v" , * nginxConfigMaps , err )
847
846
}
848
- cfgParams = configs .ParseConfigMap (cfm , * nginxPlus , * appProtect , * appProtectDos , * enableTLSPassthrough )
847
+ cfgParams = configs .ParseConfigMap (cfgParams . Context , cfm , * nginxPlus , * appProtect , * appProtectDos , * enableTLSPassthrough )
849
848
if cfgParams .MainServerSSLDHParamFileContent != nil {
850
849
fileName , err := nginxManager .CreateDHParam (* cfgParams .MainServerSSLDHParamFileContent )
851
850
if err != nil {
0 commit comments