Skip to content

Commit 1389c03

Browse files
committed
Aligns API Fields with K8s Conventions
1 parent 5716828 commit 1389c03

21 files changed

+310
-100
lines changed

apis/v1alpha1/backendpolicy_types.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ type BackendPolicy struct {
3434
metav1.TypeMeta `json:",inline"`
3535
metav1.ObjectMeta `json:"metadata,omitempty"`
3636

37-
Spec BackendPolicySpec `json:"spec,omitempty"`
37+
// Spec defines the desired state of BackendPolicy.
38+
Spec BackendPolicySpec `json:"spec,omitempty"`
39+
40+
// Status defines the current state of BackendPolicy.
3841
Status BackendPolicyStatus `json:"status,omitempty"`
3942
}
4043

4144
// +kubebuilder:object:root=true
4245

43-
// BackendPolicyList contains a list of BackendPolicy
46+
// BackendPolicyList contains a list of BackendPolicy.
4447
type BackendPolicyList struct {
4548
metav1.TypeMeta `json:",inline"`
4649
metav1.ListMeta `json:"metadata,omitempty"`
@@ -55,33 +58,39 @@ type BackendPolicySpec struct {
5558
// the oldest BackendPolicy.
5659
//
5760
// Support: Core
61+
//
5862
// +kubebuilder:validation:MaxItems=16
5963
BackendRefs []BackendRef `json:"backendRefs"`
6064

6165
// TLS is the TLS configuration for these backends.
6266
//
6367
// Support: Extended
68+
//
6469
// +optional
6570
TLS *BackendTLSConfig `json:"tls,omitempty"`
6671
}
6772

68-
// BackendRef identifies an API object within a known namespace that defaults
69-
// group to core and resource to services if unspecified.
73+
// BackendRef identifies an API object within the same namespace
74+
// as the BackendPolicy.
7075
type BackendRef struct {
7176
// Group is the group of the referent.
77+
//
7278
// +kubebuilder:validation:MaxLength=253
7379
Group string `json:"group"`
7480

7581
// Kind is the kind of the referent.
82+
//
7683
// +kubebuilder:validation:MaxLength=253
77-
Kind string `json:"kind,omitempty"`
84+
Kind string `json:"kind"`
7885

7986
// Name is the name of the referent.
87+
//
8088
// +kubebuilder:validation:MaxLength=253
8189
Name string `json:"name"`
8290

8391
// Port is the port of the referent. If unspecified, this policy applies to
8492
// all ports on the backend.
93+
//
8594
// +optional
8695
Port *PortNumber `json:"port,omitempty"`
8796
}
@@ -108,12 +117,13 @@ type BackendTLSConfig struct {
108117
// provider.
109118
//
110119
// Support: Implementation-specific.
120+
//
111121
// +optional
112122
Options map[string]string `json:"options,omitempty"`
113123
}
114124

115125
// BackendPolicyStatus defines the observed state of BackendPolicy. Conditions
116-
// that are related to a specific Route or Gateway should be placed on the
126+
// that are related to a specific Route or Gateway must be placed on the
117127
// Route(s) using backends configured by this BackendPolicy.
118128
type BackendPolicyStatus struct {
119129
// Conditions describe the current conditions of the BackendPolicy.

apis/v1alpha1/gateway_types.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@ type Gateway struct {
3737
metav1.TypeMeta `json:",inline"`
3838
metav1.ObjectMeta `json:"metadata,omitempty"`
3939

40+
// Spec defines the desired state of Gateway.
4041
Spec GatewaySpec `json:"spec,omitempty"`
4142

43+
// Status defines the current state of Gateway.
44+
//
4245
// +kubebuilder:default={conditions: {{type: "Scheduled", status: "False", reason:"NotReconciled", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
4346
Status GatewayStatus `json:"status,omitempty"`
4447
}
4548

4649
// +kubebuilder:object:root=true
4750

48-
// GatewayList contains a list of Gateway
51+
// GatewayList contains a list of Gateway.
4952
type GatewayList struct {
5053
metav1.TypeMeta `json:",inline"`
5154
metav1.ListMeta `json:"metadata,omitempty"`
@@ -61,6 +64,7 @@ type GatewayList struct {
6164
type GatewaySpec struct {
6265
// GatewayClassName used for this Gateway. This is the name of a
6366
// GatewayClass resource.
67+
//
6468
// +kubebuilder:validation:MinLength=1
6569
// +kubebuilder:validation:MaxLength=253
6670
GatewayClassName string `json:"gatewayClassName"`
@@ -293,8 +297,9 @@ type TLSOverridePolicy struct {
293297
//
294298
// Support: Core
295299
//
300+
// +optional
296301
// +kubebuilder:default=Deny
297-
Certificate TLSRouteOverrideType `json:"certificate"`
302+
Certificate TLSRouteOverrideType `json:"certificate,omitempty"`
298303
}
299304

300305
// GatewayTLSConfig describes a TLS configuration.
@@ -319,6 +324,7 @@ type GatewayTLSConfig struct {
319324
//
320325
// Support: Core
321326
//
327+
// +optional
322328
// +kubebuilder:default=Terminate
323329
Mode TLSModeType `json:"mode,omitempty"`
324330

@@ -338,7 +344,7 @@ type GatewayTLSConfig struct {
338344
// Support: Implementation-specific (Other resource types)
339345
//
340346
// +optional
341-
CertificateRef LocalObjectReference `json:"certificateRef,omitempty"`
347+
CertificateRef *LocalObjectReference `json:"certificateRef,omitempty"`
342348

343349
// RouteOverride dictates if TLS settings can be configured
344350
// via Routes or not.
@@ -349,6 +355,7 @@ type GatewayTLSConfig struct {
349355
//
350356
// Support: Core
351357
//
358+
// +optional
352359
// +kubebuilder:default={certificate:Deny}
353360
RouteOverride TLSOverridePolicy `json:"routeOverride,omitempty"`
354361

@@ -363,7 +370,7 @@ type GatewayTLSConfig struct {
363370
// Support: Implementation-specific.
364371
//
365372
// +optional
366-
Options map[string]string `json:"options"`
373+
Options map[string]string `json:"options,omitempty"`
367374
}
368375

369376
// TLSModeType type defines behavior of gateway with TLS protocol.
@@ -391,8 +398,10 @@ type RouteBindingSelector struct {
391398
// default.
392399
//
393400
// Support: Core
394-
// +kubebuilder:default={from: "Same"}
395-
Namespaces *RouteNamespaces `json:"namespaces,omitempty"`
401+
//
402+
// +optional
403+
// +kubebuilder:default={from: Same}
404+
Namespaces RouteNamespaces `json:"namespaces,omitempty"`
396405
// Selector specifies a set of route labels used for selecting
397406
// routes to associate with the Gateway. If this Selector is defined,
398407
// only routes matching the Selector are associated with the Gateway.
@@ -418,6 +427,7 @@ type RouteBindingSelector struct {
418427
//
419428
// Support: Core
420429
//
430+
// +optional
421431
// +kubebuilder:default=networking.x-k8s.io
422432
// +kubebuilder:validation:MinLength=1
423433
// +kubebuilder:validation:MaxLength=253
@@ -436,8 +446,8 @@ type RouteBindingSelector struct {
436446
}
437447

438448
// RouteSelectType specifies where Routes should be selected by a Gateway.
449+
//
439450
// +kubebuilder:validation:Enum=All;Selector;Same
440-
// +kubebuilder:default=Same
441451
type RouteSelectType string
442452

443453
const (
@@ -462,6 +472,9 @@ type RouteNamespaces struct {
462472
// * Same: Only Routes in the same namespace may be used by this Gateway.
463473
//
464474
// Support: Core
475+
//
476+
// +optional
477+
// +kubebuilder:default=Same
465478
From RouteSelectType `json:"from,omitempty"`
466479

467480
// Selector must be specified when From is set to "Selector". In that case,
@@ -480,6 +493,7 @@ type GatewayAddress struct {
480493
//
481494
// Support: Extended
482495
//
496+
// +optional
483497
// +kubebuilder:default=IPAddress
484498
Type AddressType `json:"type,omitempty"`
485499

@@ -540,7 +554,7 @@ type GatewayStatus struct {
540554
//
541555
// +optional
542556
// +kubebuilder:validation:MaxItems=16
543-
Addresses []GatewayAddress `json:"addresses"`
557+
Addresses []GatewayAddress `json:"addresses,omitempty"`
544558

545559
// Conditions describe the current conditions of the Gateway.
546560
//
@@ -554,6 +568,7 @@ type GatewayStatus struct {
554568
// * "Scheduled"
555569
// * "Ready"
556570
//
571+
// +optional
557572
// +listType=map
558573
// +listMapKey=type
559574
// +kubebuilder:validation:MaxItems=8

apis/v1alpha1/gatewayclass_types.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ import (
3131
// for creating Gateway resources.
3232
//
3333
// GatewayClass is a Cluster level resource.
34-
//
35-
// Support: Core.
3634
type GatewayClass struct {
3735
metav1.TypeMeta `json:",inline"`
3836
metav1.ObjectMeta `json:"metadata,omitempty"`
3937

40-
// Spec for this GatewayClass.
38+
// Spec defines the desired state of GatewayClass.
4139
Spec GatewayClassSpec `json:"spec,omitempty"`
42-
// Status of the GatewayClass.
40+
41+
// Status defines the current state of GatewayClass.
42+
//
4343
// +kubebuilder:default={conditions: {{type: "Admitted", status: "False", message: "Waiting for controller", reason: "Waiting", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
4444
Status GatewayClassStatus `json:"status,omitempty"`
4545
}
@@ -113,6 +113,7 @@ type GatewayClassStatus struct {
113113
// Conditions is the current status from the controller for
114114
// this GatewayClass.
115115
//
116+
// +optional
116117
// +listType=map
117118
// +listMapKey=type
118119
// +kubebuilder:validation:MaxItems=8

0 commit comments

Comments
 (0)