Skip to content

Commit 1642f36

Browse files
committed
Review feedback
1 parent 7ea76a7 commit 1642f36

File tree

7 files changed

+35
-25
lines changed

7 files changed

+35
-25
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ HELM_SCHEMA_VERSION = 0.18.1
4545
PREFIX ?= nginx-gateway-fabric## The name of the NGF image. For example, nginx-gateway-fabric
4646
NGINX_PREFIX ?= $(PREFIX)/nginx## The name of the nginx image. For example: nginx-gateway-fabric/nginx
4747
NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. For example: nginx-gateway-fabric/nginx-plus
48-
NGINX_PLUS_WAF_PREFIX ?= $(PREFIX)/nginx-plus-waf## The name of the nginx plus image with NAP WAF. For example: nginx-gateway-fabric/nginx-plus-waf
4948
TAG ?= $(VERSION:v%=%)## The tag of the image. For example, 1.1.0
5049
TARGET ?= local## The target of the build. Possible values: local and container
5150
OUT_DIR ?= build/out## The folder where the binary will be stored
@@ -110,7 +109,7 @@ build-nginx-plus-image-with-nap-waf: check-for-docker ## Build the custom nginx
110109
@if [ $(GOARCH) = "arm64" ]; then \
111110
echo "\033[0;31mIMPORTANT:\033[0m The nginx-plus-waf image cannot be built for arm64 architecture and will be built for amd64."; \
112111
fi
113-
docker build --platform linux/amd64 $(strip $(NGINX_DOCKER_BUILD_OPTIONS)) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS)) $(strip $(NGINX_DOCKER_BUILD_NAP_WAF_ARGS)) -f $(SELF_DIR)build/Dockerfile.nginxplus -t $(strip $(NGINX_PLUS_WAF_PREFIX)):$(strip $(TAG)) $(strip $(SELF_DIR))
112+
docker build --platform linux/amd64 $(strip $(NGINX_DOCKER_BUILD_OPTIONS)) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS)) $(strip $(NGINX_DOCKER_BUILD_NAP_WAF_ARGS)) -f $(SELF_DIR)build/Dockerfile.nginxplus -t $(strip $(NGINX_PLU_PREFIX)):$(strip $(TAG)) $(strip $(SELF_DIR))
114113

115114
.PHONY: check-for-docker
116115
check-for-docker: ## Check if Docker is installed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ type NginxProxySpec struct {
7575
// WAF enables NGINX App Protect WAF functionality.
7676
// When enabled, NGINX Gateway Fabric will deploy additional WAF containers
7777
// (waf-enforcer and waf-config-mgr) alongside the main NGINX container.
78-
// Default is "Disabled".
78+
// Default is "disabled".
7979
//
8080
// +optional
81-
// +kubebuilder:default:=Disabled
81+
// +kubebuilder:default:=disabled
8282
WAF *WAFState `json:"waf,omitempty"`
8383
// Kubernetes contains the configuration for the NGINX Deployment and Service Kubernetes objects.
8484
//
@@ -88,17 +88,17 @@ type NginxProxySpec struct {
8888

8989
// WAFState defines the state of WAF functionality.
9090
//
91-
// +kubebuilder:validation:Enum=Enabled;Disabled
91+
// +kubebuilder:validation:Enum=enabled;disabled
9292
type WAFState string
9393

9494
const (
9595
// WAFEnabled enables NGINX App Protect WAF functionality.
9696
// This will deploy additional containers for WAF enforcement and configuration management.
97-
WAFEnabled WAFState = "Enabled"
97+
WAFEnabled WAFState = "enabled"
9898

9999
// WAFDisabled disables NGINX App Protect WAF functionality.
100100
// Only the standard NGINX container will be deployed.
101-
WAFDisabled WAFState = "Disabled"
101+
WAFDisabled WAFState = "disabled"
102102
)
103103

104104
// Telemetry specifies the OpenTelemetry configuration.

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7771,15 +7771,15 @@ spec:
77717771
x-kubernetes-list-type: map
77727772
type: object
77737773
waf:
7774-
default: Disabled
7774+
default: disabled
77757775
description: |-
77767776
WAF enables NGINX App Protect WAF functionality.
77777777
When enabled, NGINX Gateway Fabric will deploy additional WAF containers
77787778
(waf-enforcer and waf-config-mgr) alongside the main NGINX container.
7779-
Default is "Disabled".
7779+
Default is "disabled".
77807780
enum:
7781-
- Enabled
7782-
- Disabled
7781+
- enabled
7782+
- disabled
77837783
type: string
77847784
type: object
77857785
required:

deploy/crds.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8356,15 +8356,15 @@ spec:
83568356
x-kubernetes-list-type: map
83578357
type: object
83588358
waf:
8359-
default: Disabled
8359+
default: disabled
83608360
description: |-
83618361
WAF enables NGINX App Protect WAF functionality.
83628362
When enabled, NGINX Gateway Fabric will deploy additional WAF containers
83638363
(waf-enforcer and waf-config-mgr) alongside the main NGINX container.
8364-
Default is "Disabled".
8364+
Default is "disabled".
83658365
enum:
8366-
- Enabled
8367-
- Disabled
8366+
- enabled
8367+
- disabled
83688368
type: string
83698369
type: object
83708370
required:

internal/controller/provisioner/objects.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ const (
3333
defaultServiceType = corev1.ServiceTypeLoadBalancer
3434
defaultServicePolicy = corev1.ServiceExternalTrafficPolicyLocal
3535

36-
defaultNginxImagePath = "ghcr.io/nginx/nginx-gateway-fabric/nginx"
37-
defaultNginxPlusImagePath = "private-registry.nginx.com/nginx-gateway-fabric/nginx-plus"
38-
defaultNginxPlusWafImagePath = "private-registry.nginx.com/nginx-gateway-fabric/nginx-plus-waf"
39-
defaultImagePullPolicy = corev1.PullIfNotPresent
36+
defaultNginxImagePath = "ghcr.io/nginx/nginx-gateway-fabric/nginx"
37+
defaultImagePullPolicy = corev1.PullIfNotPresent
4038

4139
// WAF container defaults.
4240
defaultWAFEnforcerImagePath = "private-registry.nginx.com/nap/waf-enforcer"
@@ -914,7 +912,8 @@ func (p *NginxProvisioner) configureNginxPlus(
914912
initCmd = append(initCmd,
915913
"--source", "/includes/mgmt.conf",
916914
"--destination", "/etc/nginx/main-includes",
917-
"--nginx-plus")
915+
"--nginx-plus",
916+
)
918917
spec.Spec.InitContainers[0].Command = initCmd
919918

920919
// Add NGINX Plus volumes and volume mounts
@@ -984,10 +983,6 @@ func (p *NginxProvisioner) buildImage(nProxyCfg *graph.EffectiveNginxProxy) (str
984983
tag := p.cfg.GatewayPodConfig.Version
985984
pullPolicy := defaultImagePullPolicy
986985

987-
if graph.WAFEnabledForNginxProxy(nProxyCfg) {
988-
image = defaultNginxPlusWafImagePath
989-
}
990-
991986
getImageAndPullPolicy := func(container ngfAPIv1alpha2.ContainerSpec) (string, string, corev1.PullPolicy) {
992987
if container.Image != nil {
993988
if container.Image.Repository != nil {

internal/controller/provisioner/objects_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ func TestBuildNginxResourceObjects_WAF(t *testing.T) {
11141114
// Validate NGINX container (first container)
11151115
nginxContainer := template.Spec.Containers[0]
11161116
g.Expect(nginxContainer.Name).To(Equal("nginx"))
1117-
g.Expect(nginxContainer.Image).To(Equal(fmt.Sprintf("%s:1.0.0", defaultNginxPlusWafImagePath)))
1117+
g.Expect(nginxContainer.Image).To(Equal(fmt.Sprintf("%s:1.0.0", defaultNginxImagePath)))
11181118

11191119
// Check NGINX container has WAF volume mounts
11201120
wafVolumeMountNames := []string{

internal/controller/state/graph/nginxproxy_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,22 @@ func TestBuildEffectiveNginxProxy_WAF(t *testing.T) {
536536
WAF: helpers.GetPointer(ngfAPIv1alpha2.WAFDisabled),
537537
},
538538
},
539+
{
540+
name: "both have WAF unset",
541+
gcNp: &NginxProxy{
542+
Valid: true,
543+
Source: &ngfAPIv1alpha2.NginxProxy{
544+
Spec: ngfAPIv1alpha2.NginxProxySpec{},
545+
},
546+
},
547+
gwNp: &NginxProxy{
548+
Valid: true,
549+
Source: &ngfAPIv1alpha2.NginxProxy{
550+
Spec: ngfAPIv1alpha2.NginxProxySpec{},
551+
},
552+
},
553+
exp: &EffectiveNginxProxy{},
554+
},
539555
}
540556

541557
for _, test := range tests {

0 commit comments

Comments
 (0)