-
Notifications
You must be signed in to change notification settings - Fork 529
Aligns API Fields with K8s Conventions #538
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,15 +37,18 @@ type Gateway struct { | |
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// Spec defines the desired state of Gateway. | ||
Spec GatewaySpec `json:"spec,omitempty"` | ||
|
||
// Status defines the current state of Gateway. | ||
// | ||
// +kubebuilder:default={conditions: {{type: "Scheduled", status: "False", reason:"NotReconciled", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}} | ||
Status GatewayStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// GatewayList contains a list of Gateway | ||
// GatewayList contains a list of Gateway. | ||
type GatewayList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
|
@@ -61,6 +64,7 @@ type GatewayList struct { | |
type GatewaySpec struct { | ||
// GatewayClassName used for this Gateway. This is the name of a | ||
// GatewayClass resource. | ||
// | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=253 | ||
GatewayClassName string `json:"gatewayClassName"` | ||
|
@@ -293,8 +297,9 @@ type TLSOverridePolicy struct { | |
// | ||
// Support: Core | ||
// | ||
// +optional | ||
// +kubebuilder:default=Deny | ||
Certificate TLSRouteOverrideType `json:"certificate"` | ||
Certificate TLSRouteOverrideType `json:"certificate,omitempty"` | ||
Comment on lines
+300
to
+302
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +optional/omitempty was added since this field is being defaulted. |
||
} | ||
|
||
// GatewayTLSConfig describes a TLS configuration. | ||
|
@@ -319,6 +324,7 @@ type GatewayTLSConfig struct { | |
// | ||
// Support: Core | ||
// | ||
// +optional | ||
// +kubebuilder:default=Terminate | ||
Mode TLSModeType `json:"mode,omitempty"` | ||
|
||
|
@@ -338,7 +344,7 @@ type GatewayTLSConfig struct { | |
// Support: Implementation-specific (Other resource types) | ||
// | ||
// +optional | ||
CertificateRef LocalObjectReference `json:"certificateRef,omitempty"` | ||
CertificateRef *LocalObjectReference `json:"certificateRef,omitempty"` | ||
|
||
// RouteOverride dictates if TLS settings can be configured | ||
// via Routes or not. | ||
|
@@ -349,6 +355,7 @@ type GatewayTLSConfig struct { | |
// | ||
// Support: Core | ||
// | ||
// +optional | ||
// +kubebuilder:default={certificate:Deny} | ||
RouteOverride TLSOverridePolicy `json:"routeOverride,omitempty"` | ||
|
||
|
@@ -363,7 +370,7 @@ type GatewayTLSConfig struct { | |
// Support: Implementation-specific. | ||
// | ||
// +optional | ||
Options map[string]string `json:"options"` | ||
Options map[string]string `json:"options,omitempty"` | ||
} | ||
|
||
// TLSModeType type defines behavior of gateway with TLS protocol. | ||
|
@@ -391,8 +398,10 @@ type RouteBindingSelector struct { | |
// default. | ||
// | ||
// Support: Core | ||
// +kubebuilder:default={from: "Same"} | ||
Namespaces *RouteNamespaces `json:"namespaces,omitempty"` | ||
// | ||
// +optional | ||
// +kubebuilder:default={from: Same} | ||
Namespaces RouteNamespaces `json:"namespaces,omitempty"` | ||
// Selector specifies a set of route labels used for selecting | ||
// routes to associate with the Gateway. If this Selector is defined, | ||
// only routes matching the Selector are associated with the Gateway. | ||
|
@@ -418,6 +427,7 @@ type RouteBindingSelector struct { | |
// | ||
// Support: Core | ||
// | ||
// +optional | ||
// +kubebuilder:default=networking.x-k8s.io | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=253 | ||
|
@@ -436,8 +446,8 @@ type RouteBindingSelector struct { | |
} | ||
|
||
// RouteSelectType specifies where Routes should be selected by a Gateway. | ||
// | ||
// +kubebuilder:validation:Enum=All;Selector;Same | ||
// +kubebuilder:default=Same | ||
type RouteSelectType string | ||
|
||
const ( | ||
|
@@ -462,6 +472,9 @@ type RouteNamespaces struct { | |
// * Same: Only Routes in the same namespace may be used by this Gateway. | ||
// | ||
// Support: Core | ||
// | ||
// +optional | ||
// +kubebuilder:default=Same | ||
From RouteSelectType `json:"from,omitempty"` | ||
|
||
// Selector must be specified when From is set to "Selector". In that case, | ||
|
@@ -480,6 +493,7 @@ type GatewayAddress struct { | |
// | ||
// Support: Extended | ||
// | ||
// +optional | ||
// +kubebuilder:default=IPAddress | ||
Type AddressType `json:"type,omitempty"` | ||
|
||
|
@@ -540,7 +554,7 @@ type GatewayStatus struct { | |
// | ||
// +optional | ||
// +kubebuilder:validation:MaxItems=16 | ||
Addresses []GatewayAddress `json:"addresses"` | ||
Addresses []GatewayAddress `json:"addresses,omitempty"` | ||
|
||
// Conditions describe the current conditions of the Gateway. | ||
// | ||
|
@@ -554,6 +568,7 @@ type GatewayStatus struct { | |
// * "Scheduled" | ||
// * "Ready" | ||
// | ||
// +optional | ||
// +listType=map | ||
// +listMapKey=type | ||
// +kubebuilder:validation:MaxItems=8 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,15 +31,15 @@ import ( | |
// for creating Gateway resources. | ||
// | ||
// GatewayClass is a Cluster level resource. | ||
// | ||
// Support: Core. | ||
Comment on lines
-34
to
-35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fields should indicate the support-level and not the top-level resource. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there may be a place for this, especially for route types, but I'm not exactly sure what that should be. I think we want a world where both L4 and L7 implementations can support different parts of this API. I don't mind removing this here though since it doesn't seem like we've added it for other resources. |
||
type GatewayClass struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// Spec for this GatewayClass. | ||
// Spec defines the desired state of GatewayClass. | ||
Spec GatewayClassSpec `json:"spec,omitempty"` | ||
// Status of the GatewayClass. | ||
|
||
// Status defines the current state of GatewayClass. | ||
// | ||
// +kubebuilder:default={conditions: {{type: "Admitted", status: "False", message: "Waiting for controller", reason: "Waiting", lastTransitionTime: "1970-01-01T00:00:00Z"}}} | ||
Status GatewayClassStatus `json:"status,omitempty"` | ||
} | ||
|
@@ -113,6 +113,7 @@ type GatewayClassStatus struct { | |
// Conditions is the current status from the controller for | ||
// this GatewayClass. | ||
// | ||
// +optional | ||
// +listType=map | ||
// +listMapKey=type | ||
// +kubebuilder:validation:MaxItems=8 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be the other way around where we remove the
omitempty
tag. An object without aspec
is going to confuse users and even maintainers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we OK diverging from how upstream defines spec/status/metadata optionality?
xref: https://github.com/kubernetes/api/blob/master/core/v1/types.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As strange as it is, I think it likely is appropriate to follow what upstream is doing here.