Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor, set staticSSLPath to a variable for reuse #6872

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
parsedFlags := os.Args[1:]

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

Check warning on line 91 in cmd/nginx-ingress/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nginx-ingress/main.go#L91

Added line #L91 was not covered by tests

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

isWildcardEnabled := processWildcardSecret(ctx, kubeClient, nginxManager)

staticSSLPath := nginxManager.GetSecretsDir()

Check warning on line 151 in cmd/nginx-ingress/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nginx-ingress/main.go#L150-L151

Added lines #L150 - L151 were not covered by tests
globalConfigurationValidator := createGlobalConfigurationValidator()

mustProcessGlobalConfiguration(ctx)
Expand Down Expand Up @@ -177,7 +180,7 @@
EnableCertManager: *enableCertManager,
DynamicSSLReload: *enableDynamicSSLReload,
DynamicWeightChangesReload: *enableDynamicWeightChangesReload,
StaticSSLPath: nginxManager.GetSecretsDir(),
StaticSSLPath: staticSSLPath,

Check warning on line 183 in cmd/nginx-ingress/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nginx-ingress/main.go#L183

Added line #L183 was not covered by tests
NginxVersion: nginxVersion,
AppProtectBundlePath: appProtectBundlePath,
}
Expand Down Expand Up @@ -211,8 +214,6 @@
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
Loading