Skip to content

Commit

Permalink
set staticSSLPath to a variable for reuse (#6872)
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Ryan <[email protected]>
  • Loading branch information
AlexFenlon and j1m-ryan authored Nov 27, 2024
1 parent 2767500 commit 7e7535d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func main() {
parsedFlags := os.Args[1:]

buildOS := os.Getenv("BUILD_OS")
controllerNamespace := os.Getenv("POD_NAMESPACE")

config, kubeClient := mustCreateConfigAndKubeClient(ctx)
mustValidateKubernetesVersionInfo(ctx, kubeClient)
Expand Down Expand Up @@ -146,6 +147,8 @@ func main() {

isWildcardEnabled := processWildcardSecret(ctx, kubeClient, nginxManager)

staticSSLPath := nginxManager.GetSecretsDir()

globalConfigurationValidator := createGlobalConfigurationValidator()

mustProcessGlobalConfiguration(ctx)
Expand Down Expand Up @@ -177,7 +180,7 @@ func main() {
EnableCertManager: *enableCertManager,
DynamicSSLReload: *enableDynamicSSLReload,
DynamicWeightChangesReload: *enableDynamicWeightChangesReload,
StaticSSLPath: nginxManager.GetSecretsDir(),
StaticSSLPath: staticSSLPath,
NginxVersion: nginxVersion,
AppProtectBundlePath: appProtectBundlePath,
}
Expand Down Expand Up @@ -211,8 +214,6 @@ func main() {
NginxVersion: nginxVersion,
})

controllerNamespace := os.Getenv("POD_NAMESPACE")

transportServerValidator := cr_validation.NewTransportServerValidator(*enableTLSPassthrough, *enableSnippets, *nginxPlus)
virtualServerValidator := cr_validation.NewVirtualServerValidator(
cr_validation.IsPlus(*nginxPlus),
Expand Down
11 changes: 11 additions & 0 deletions internal/configs/version1/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/nginxinc/kubernetes-ingress/internal/nginx"
)

var fakeManager = nginx.NewFakeManager("/etc/nginx")

func TestMain(m *testing.M) {
v := m.Run()

Expand Down Expand Up @@ -2017,6 +2019,7 @@ var (
}

mainCfg = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 80,
DefaultHTTPSListenerPort: 443,
ServerNamesHashMaxSize: "512",
Expand Down Expand Up @@ -2061,6 +2064,7 @@ var (
}

mainCfgR31 = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 80,
DefaultHTTPSListenerPort: 443,
ServerNamesHashMaxSize: "512",
Expand Down Expand Up @@ -2090,6 +2094,7 @@ var (
}

mainCfgHTTP2On = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 80,
DefaultHTTPSListenerPort: 443,
HTTP2: true,
Expand Down Expand Up @@ -2130,6 +2135,7 @@ var (
}

mainCfgCustomTLSPassthroughPort = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
ServerNamesHashMaxSize: "512",
ServerTokens: "off",
WorkerProcesses: "auto",
Expand Down Expand Up @@ -2157,6 +2163,7 @@ var (
}

mainCfgWithoutTLSPassthrough = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
ServerNamesHashMaxSize: "512",
ServerTokens: "off",
WorkerProcesses: "auto",
Expand Down Expand Up @@ -2184,6 +2191,7 @@ var (
}

mainCfgDefaultTLSPassthroughPort = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
ServerNamesHashMaxSize: "512",
ServerTokens: "off",
WorkerProcesses: "auto",
Expand Down Expand Up @@ -2211,6 +2219,7 @@ var (
}

mainCfgCustomDefaultHTTPAndHTTPSListenerPorts = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 8083,
DefaultHTTPSListenerPort: 8443,
ServerNamesHashMaxSize: "512",
Expand Down Expand Up @@ -2238,6 +2247,7 @@ var (
}

mainCfgCustomDefaultHTTPListenerPort = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 8083,
DefaultHTTPSListenerPort: 443,
ServerNamesHashMaxSize: "512",
Expand Down Expand Up @@ -2265,6 +2275,7 @@ var (
}

mainCfgCustomDefaultHTTPSListenerPort = MainConfig{
StaticSSLPath: fakeManager.GetSecretsDir(),
DefaultHTTPListenerPort: 80,
DefaultHTTPSListenerPort: 8443,
ServerNamesHashMaxSize: "512",
Expand Down

0 comments on commit 7e7535d

Please sign in to comment.