Skip to content

Commit 43ce54d

Browse files
committed
Review feedback and fix CRD validation
1 parent 3bd8572 commit 43ce54d

File tree

14 files changed

+83
-78
lines changed

14 files changed

+83
-78
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,30 +365,27 @@ type NginxPlus struct {
365365
// Corresponds to the NGINX resolver directive: https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
366366
type DNSResolver struct {
367367
// Timeout specifies the timeout for name resolution.
368-
// Default: 30s.
369368
//
370369
// +optional
371370
Timeout *v1alpha1.Duration `json:"timeout,omitempty"`
372371

373372
// CacheTTL specifies how long to cache DNS responses.
374-
// Default: 30s.
375373
//
376374
// +optional
377375
CacheTTL *v1alpha1.Duration `json:"cacheTTL,omitempty"`
378376

379-
// IPv6 enables IPv6 lookups.
380-
// Default: true.
377+
// DisableIPv6 disables DisableIPv6 lookups.
378+
// If not specified, or set to false, IPv6 lookups will be enabled.
381379
//
382380
// +optional
383-
IPv6 *bool `json:"ipv6,omitempty"`
381+
DisableIPv6 *bool `json:"ipv6,omitempty"`
384382

385383
// Addresses specifies the list of DNS server addresses.
386384
// Each address can be an IP address or hostname.
387385
// Example: [{"type": "IPAddress", "value": "8.8.8.8"}, {"type": "Hostname", "value": "dns.google"}]
388386
//
389387
// +kubebuilder:validation:MinItems=1
390388
// +kubebuilder:validation:MaxItems=16
391-
// +listType=set
392389
Addresses []DNSResolverAddress `json:"addresses"`
393390
}
394391

@@ -398,6 +395,11 @@ type DNSResolverAddress struct {
398395
Type DNSResolverAddressType `json:"type"`
399396

400397
// Value specifies the address value.
398+
// When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
399+
// When Type is "Hostname", this must be a valid hostname.
400+
//
401+
// +kubebuilder:validation:MinLength=1
402+
// +kubebuilder:validation:MaxLength=253
401403
Value string `json:"value"`
402404
}
403405

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/nginx-gateway-fabric/values.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,24 @@
154154
],
155155
"type": "object"
156156
},
157+
"maxItems": 16,
157158
"minItems": 1,
158159
"required": [],
159160
"type": "array"
160161
},
161162
"cacheTTL": {
162-
"description": "CacheTTL specifies how long to cache DNS responses. Default is 30s.",
163+
"description": "CacheTTL specifies how long to cache DNS responses.",
163164
"pattern": "^\\d+[smhd]?$",
164165
"required": [],
165166
"type": "string"
166167
},
167-
"ipv6": {
168-
"description": "IPv6 enables IPv6 lookups. Default is true.",
168+
"disableIPv6": {
169+
"description": "DisableIPv6 disables DisableIPv6 lookups. If not specified, or set to false, IPv6 lookups will be enabled.",
169170
"required": [],
170171
"type": "boolean"
171172
},
172173
"timeout": {
173-
"description": "Timeout specifies the timeout for name resolution. Default is 30s.",
174+
"description": "Timeout specifies the timeout for name resolution.",
174175
"pattern": "^\\d+[smhd]?$",
175176
"required": [],
176177
"type": "string"

charts/nginx-gateway-fabric/values.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,18 @@ nginx:
485485
# - type
486486
# - value
487487
# minItems: 1
488+
# maxItems: 16
488489
# timeout:
489490
# type: string
490-
# description: Timeout specifies the timeout for name resolution. Default is 30s.
491+
# description: Timeout specifies the timeout for name resolution.
491492
# pattern: ^\d+[smhd]?$
492493
# cacheTTL:
493494
# type: string
494-
# description: CacheTTL specifies how long to cache DNS responses. Default is 30s.
495+
# description: CacheTTL specifies how long to cache DNS responses.
495496
# pattern: ^\d+[smhd]?$
496-
# ipv6:
497+
# disableIPv6:
497498
# type: boolean
498-
# description: IPv6 enables IPv6 lookups. Default is true.
499+
# description: DisableIPv6 disables DisableIPv6 lookups. If not specified, or set to false, IPv6 lookups will be enabled.
499500
# @schema
500501
# -- The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways
501502
# managed by this instance of NGINX Gateway Fabric.

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ spec:
8686
- Hostname
8787
type: string
8888
value:
89-
description: Value specifies the address value.
89+
description: |-
90+
Value specifies the address value.
91+
When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
92+
When Type is "Hostname", this must be a valid hostname.
93+
maxLength: 253
94+
minLength: 1
9095
type: string
9196
required:
9297
- type
@@ -95,22 +100,17 @@ spec:
95100
maxItems: 16
96101
minItems: 1
97102
type: array
98-
x-kubernetes-list-type: set
99103
cacheTTL:
100-
description: |-
101-
CacheTTL specifies how long to cache DNS responses.
102-
Default: 30s.
104+
description: CacheTTL specifies how long to cache DNS responses.
103105
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
104106
type: string
105107
ipv6:
106108
description: |-
107-
IPv6 enables IPv6 lookups.
108-
Default: true.
109+
DisableIPv6 disables DisableIPv6 lookups.
110+
If not specified, or set to false, IPv6 lookups will be enabled.
109111
type: boolean
110112
timeout:
111-
description: |-
112-
Timeout specifies the timeout for name resolution.
113-
Default: 30s.
113+
description: Timeout specifies the timeout for name resolution.
114114
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
115115
type: string
116116
required:

deploy/crds.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,12 @@ spec:
671671
- Hostname
672672
type: string
673673
value:
674-
description: Value specifies the address value.
674+
description: |-
675+
Value specifies the address value.
676+
When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
677+
When Type is "Hostname", this must be a valid hostname.
678+
maxLength: 253
679+
minLength: 1
675680
type: string
676681
required:
677682
- type
@@ -680,22 +685,17 @@ spec:
680685
maxItems: 16
681686
minItems: 1
682687
type: array
683-
x-kubernetes-list-type: set
684688
cacheTTL:
685-
description: |-
686-
CacheTTL specifies how long to cache DNS responses.
687-
Default: 30s.
689+
description: CacheTTL specifies how long to cache DNS responses.
688690
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
689691
type: string
690692
ipv6:
691693
description: |-
692-
IPv6 enables IPv6 lookups.
693-
Default: true.
694+
DisableIPv6 disables DisableIPv6 lookups.
695+
If not specified, or set to false, IPv6 lookups will be enabled.
694696
type: boolean
695697
timeout:
696-
description: |-
697-
Timeout specifies the timeout for name resolution.
698-
Default: 30s.
698+
description: Timeout specifies the timeout for name resolution.
699699
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
700700
type: string
701701
required:

internal/controller/nginx/config/base_http_config_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const baseHTTPTemplateText = `
66
77
{{- if .DNSResolver }}
88
# DNS resolver configuration for ExternalName services
9-
resolver {{ range $i, $addr := .DNSResolver.Addresses }}{{ if $i }} {{ end }}{{ $addr }}{{ end }}{{ if .DNSResolver.Valid }} valid={{ .DNSResolver.Valid }}{{ end }}{{ if not .DNSResolver.IPv6 }} ipv6=off{{ end }};
9+
resolver{{ range $addr := .DNSResolver.Addresses }} {{ $addr }}{{ end }}{{ if .DNSResolver.Valid }} valid={{ .DNSResolver.Valid }}{{ end }}{{ if .DNSResolver.DisableIPv6 }} ipv6=off{{ end }};
1010
{{- if .DNSResolver.Timeout }}
1111
resolver_timeout {{ .DNSResolver.Timeout }};
1212
{{- end }}

internal/controller/nginx/config/base_http_config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ func TestExecuteBaseHttp_DNSResolver(t *testing.T) {
224224
conf: dataplane.Configuration{
225225
BaseHTTPConfig: dataplane.BaseHTTPConfig{
226226
DNSResolver: &dataplane.DNSResolverConfig{
227-
Addresses: []string{"8.8.8.8", "8.8.4.4"},
228-
Timeout: "10s",
229-
Valid: "60s",
230-
IPv6: false,
227+
Addresses: []string{"8.8.8.8", "8.8.4.4"},
228+
Timeout: "10s",
229+
Valid: "60s",
230+
DisableIPv6: true,
231231
},
232232
},
233233
},
@@ -238,8 +238,8 @@ func TestExecuteBaseHttp_DNSResolver(t *testing.T) {
238238
conf: dataplane.Configuration{
239239
BaseHTTPConfig: dataplane.BaseHTTPConfig{
240240
DNSResolver: &dataplane.DNSResolverConfig{
241-
Addresses: []string{"8.8.8.8"},
242-
IPv6: true,
241+
Addresses: []string{"8.8.8.8"},
242+
DisableIPv6: false,
243243
},
244244
},
245245
},

internal/controller/nginx/config/stream_servers_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package config
44
const streamServersTemplateText = `
55
{{- if .DNSResolver }}
66
# DNS resolver configuration for ExternalName services
7-
resolver {{ range $i, $addr := .DNSResolver.Addresses }}{{ if $i }} {{ end }}{{ $addr }}{{ end }}{{ if .DNSResolver.Valid }} valid={{ .DNSResolver.Valid }}{{ end }}{{ if not .DNSResolver.IPv6 }} ipv6=off{{ end }};
7+
resolver{{ range $addr := .DNSResolver.Addresses }} {{ $addr }}{{ end }}{{ if .DNSResolver.Valid }} valid={{ .DNSResolver.Valid }}{{ end }}{{ if .DNSResolver.DisableIPv6 }} ipv6=off{{ end }};
88
{{- if .DNSResolver.Timeout }}
99
resolver_timeout {{ .DNSResolver.Timeout }};
1010
{{- end }}

internal/controller/nginx/config/stream_servers_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ func TestExecuteStreamServersWithResolver(t *testing.T) {
424424
conf: dataplane.Configuration{
425425
BaseStreamConfig: dataplane.BaseStreamConfig{
426426
DNSResolver: &dataplane.DNSResolverConfig{
427-
Addresses: []string{"8.8.8.8", "8.8.4.4"},
428-
Timeout: "10s",
429-
Valid: "60s",
430-
IPv6: false,
427+
Addresses: []string{"8.8.8.8", "8.8.4.4"},
428+
Timeout: "10s",
429+
Valid: "60s",
430+
DisableIPv6: true,
431431
},
432432
},
433433
},
@@ -462,10 +462,10 @@ server {
462462
conf: dataplane.Configuration{
463463
BaseStreamConfig: dataplane.BaseStreamConfig{
464464
DNSResolver: &dataplane.DNSResolverConfig{
465-
Addresses: []string{"2001:4860:4860::8888"},
466-
Timeout: "5s",
467-
Valid: "30s",
468-
IPv6: true,
465+
Addresses: []string{"2001:4860:4860::8888"},
466+
Timeout: "5s",
467+
Valid: "30s",
468+
DisableIPv6: false,
469469
},
470470
},
471471
},

0 commit comments

Comments
 (0)