Skip to content

Commit

Permalink
fix: distinct address types for Gateways
Browse files Browse the repository at this point in the history
Re-using the Gateway AddressType ended up having
problems because it would add extraneous CRD fields,
so this patch creates a new type specifically for
this purpose with single-purpose validation options.
  • Loading branch information
shaneutt committed Jan 4, 2022
1 parent 5b71013 commit 50a44ae
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 81 deletions.
14 changes: 8 additions & 6 deletions apis/v1alpha2/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ type GatewayAddress struct {
//
// +optional
// +kubebuilder:default=IPAddress
Type *AddressType `json:"type,omitempty"`
Type *GatewayAddressType `json:"type,omitempty"`

// Value of the address. The validity of the values will depend
// on the type and support by the controller.
Expand All @@ -462,14 +462,16 @@ type GatewayAddress struct {
Value string `json:"value"`
}

// AddressType defines how a network address is represented as a text string.
// GatewayAddressType defines how a network address is represented as a text
// string, specifically in the context of listener addresses for Gateways and
// includes options over the base AddressType type such as Hostname.
//
// If the requested address is unsupported, the controller
// should raise the "Detached" listener status condition on
// the Gateway with the "UnsupportedAddress" reason.
//
// +kubebuilder:validation:Enum=IPAddress;Hostname;NamedAddress
type AddressType string
type GatewayAddressType string

const (
// A textual representation of a numeric IP address. IPv4
Expand All @@ -482,22 +484,22 @@ const (
// IPAddress).
//
// Support: Extended
IPAddressType AddressType = "IPAddress"
IPAddressType GatewayAddressType = "IPAddress"

// A Hostname represents a DNS based ingress point. This is similar to the
// corresponding hostname field in Kubernetes load balancer status. For
// example, this concept may be used for cloud load balancers where a DNS
// name is used to expose a load balancer.
//
// Support: Extended
HostnameAddressType AddressType = "Hostname"
HostnameAddressType GatewayAddressType = "Hostname"

// A NamedAddress provides a way to reference a specific IP address by name.
// For example, this may be a name or other unique identifier that refers
// to a resource on a cloud provider such as a static IP.
//
// Support: Implementation-Specific
NamedAddressType AddressType = "NamedAddress"
NamedAddressType GatewayAddressType = "NamedAddress"
)

// GatewayStatus defines the observed state of Gateway.
Expand Down
8 changes: 6 additions & 2 deletions apis/v1alpha2/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ type AddressMatch struct {
// Support: Custom (NamedAddress)
//
// +optional
// +kubebuilder:validation:Enum=IPAddress;NamedAddress
// +kubebuilder:default=IPAddress
Type *AddressType `json:"type,omitempty"`

// Value of the address. The validity of the values will depend
Expand All @@ -434,3 +432,9 @@ type AddressMatch struct {
// +kubebuilder:validation:MaxLength=253
Value string `json:"value"`
}

// AddressType defines how a network address is represented as a text string.
//
// +kubebuilder:validation:Enum=IPAddress;NamedAddress
// +kubebuilder:default=IPAddress
type AddressType string
2 changes: 1 addition & 1 deletion apis/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions config/crd/experimental/gateway.networking.k8s.io_tcproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions config/crd/experimental/gateway.networking.k8s.io_udproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions config/crd/stable/gateway.networking.k8s.io_tcproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions config/crd/stable/gateway.networking.k8s.io_udproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50a44ae

Please sign in to comment.