Skip to content

Commit 09cfd3e

Browse files
authored
feat: make Gateway.Spec.Addresses.Value optional (#3616)
* feat: make `Gateway.Spec.Addresses.Value` optional * wip: test mock * feat: flag injection & change `GatewayAddress` -> `GatewaySpecAddress` * add `omitempty` to the value * chore: update codegen * fix: type validation and minLength * chore: remove conformance test for now * complete rename of `GatewayAddress` -> `GatewaySpecAddress` * fix: improve docs for value field * fix: value field doc
1 parent 20bdbcd commit 09cfd3e

File tree

15 files changed

+185
-116
lines changed

15 files changed

+185
-116
lines changed

apis/v1/gateway_types.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ type GatewaySpec struct {
264264
// +kubebuilder:validation:MaxItems=16
265265
// +kubebuilder:validation:XValidation:message="IPAddress values must be unique",rule="self.all(a1, a1.type == 'IPAddress' ? self.exists_one(a2, a2.type == a1.type && a2.value == a1.value) : true )"
266266
// +kubebuilder:validation:XValidation:message="Hostname values must be unique",rule="self.all(a1, a1.type == 'Hostname' ? self.exists_one(a2, a2.type == a1.type && a2.value == a1.value) : true )"
267-
Addresses []GatewayAddress `json:"addresses,omitempty"`
267+
Addresses []GatewaySpecAddress `json:"addresses,omitempty"`
268268

269269
// Infrastructure defines infrastructure level attributes about this Gateway instance.
270270
//
@@ -724,24 +724,27 @@ type RouteGroupKind struct {
724724
Kind Kind `json:"kind"`
725725
}
726726

727-
// GatewayAddress describes an address that can be bound to a Gateway.
727+
// GatewaySpecAddress describes an address that can be bound to a Gateway.
728728
//
729729
// +kubebuilder:validation:XValidation:message="Hostname value must only contain valid characters (matching ^(\\*\\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$)",rule="self.type == 'Hostname' ? self.value.matches(r\"\"\"^(\\*\\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\"\"\"): true"
730-
type GatewayAddress struct {
730+
type GatewaySpecAddress struct {
731731
// Type of the address.
732732
//
733733
// +optional
734734
// +kubebuilder:default=IPAddress
735735
Type *AddressType `json:"type,omitempty"`
736736

737-
// Value of the address. The validity of the values will depend
738-
// on the type and support by the controller.
737+
// When a value is unspecified, an implementation SHOULD automatically
738+
// assign an address matching the requested type if possible.
739+
//
740+
// If an implementation does not support an empty value, they MUST set the
741+
// "Programmed" condition in status to False with a reason of "AddressNotAssigned".
739742
//
740743
// Examples: `1.2.3.4`, `128::1`, `my-ip-address`.
741744
//
742-
// +kubebuilder:validation:MinLength=1
745+
// +optional
743746
// +kubebuilder:validation:MaxLength=253
744-
Value string `json:"value"`
747+
Value string `json:"value,omitempty"`
745748
}
746749

747750
// GatewayStatusAddress describes a network address that is bound to a Gateway.

apis/v1/zz_generated.deepcopy.go

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1beta1/gateway_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ type RouteGroupKind = v1.RouteGroupKind
133133

134134
// GatewayAddress describes an address that can be bound to a Gateway.
135135
// +k8s:deepcopy-gen=false
136-
type GatewayAddress = v1.GatewayAddress
136+
type GatewaySpecAddress = v1.GatewaySpecAddress
137137

138138
// GatewayStatus defines the observed state of Gateway.
139139
// +k8s:deepcopy-gen=false

applyconfiguration/apis/v1/gatewayspec.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfiguration/apis/v1/gatewayspecaddress.go

+52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfiguration/internal/internal.go

+10-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfiguration/utils.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/experimental/gateway.networking.k8s.io_gateways.yaml

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/standard/gateway.networking.k8s.io_gateways.yaml

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conformance/tests/gateway-static-addresses.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func extractStatusAddresses(addresses []v1.GatewayStatusAddress) []string {
160160
// Private Helper Functions
161161
// -----------------------------------------------------------------------------
162162

163-
func filterAddr(addrs []v1.GatewayAddress, filter v1.GatewayAddress) (newAddrs []v1.GatewayAddress) {
163+
func filterAddr(addrs []v1.GatewaySpecAddress, filter v1.GatewaySpecAddress) (newAddrs []v1.GatewaySpecAddress) {
164164
for _, addr := range addrs {
165165
if addr.Value != filter.Value {
166166
newAddrs = append(newAddrs, addr)

0 commit comments

Comments
 (0)