Skip to content

Commit

Permalink
Aligns API Fields with Kubernetes Conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
danehans committed Feb 4, 2021
1 parent 2373bf6 commit 185a2fa
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 169 deletions.
37 changes: 29 additions & 8 deletions apis/v1alpha1/backendpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,25 @@ import (
// implementation specific may be represented with similar implementation
// specific custom resources.
type BackendPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BackendPolicySpec `json:"spec,omitempty"`
// Spec defines the desired state of BackendPolicy.
//
// +optional
Spec BackendPolicySpec `json:"spec,omitempty"`

// Status defines the current state of BackendPolicy.
//
// +optional
// +kubebuilder:default={conditions: {{type: "Admitted", status: "False", message: "Waiting for controller", reason: "Waiting", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status BackendPolicyStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// BackendPolicyList contains a list of BackendPolicy
// BackendPolicyList contains a list of BackendPolicy.
type BackendPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -55,33 +64,43 @@ type BackendPolicySpec struct {
// the oldest BackendPolicy.
//
// Support: Core
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
BackendRefs []BackendRef `json:"backendRefs"`

// TLS is the TLS configuration for these backends.
//
// Support: Extended
//
// +optional
TLS *BackendTLSConfig `json:"tls,omitempty"`
TLS BackendTLSConfig `json:"tls,omitempty"`
}

// BackendRef identifies an API object within a known namespace that defaults
// group to core and resource to services if unspecified.
type BackendRef struct {
// Group is the group of the referent.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Group string `json:"group"`

// Kind is the kind of the referent.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Kind string `json:"kind,omitempty"`
Kind string `json:"kind"`

// Name is the name of the referent.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Name string `json:"name"`

// Port is the port of the referent. If unspecified, this policy applies to
// all ports on the backend.
//
// +optional
Port *PortNumber `json:"port,omitempty"`
}
Expand All @@ -102,26 +121,28 @@ type BackendTLSConfig struct {
// Support: Extended
//
// +optional
CertificateAuthorityRef *LocalObjectReference `json:"certificateAuthorityRef,omitempty"`
CertificateAuthorityRef LocalObjectReference `json:"certificateAuthorityRef,omitempty"`

// Options are a list of key/value pairs to give extended options to the
// provider.
//
// Support: Implementation-specific.
//
// +optional
Options map[string]string `json:"options,omitempty"`
}

// BackendPolicyStatus defines the observed state of BackendPolicy. Conditions
// that are related to a specific Route or Gateway should be placed on the
// that are related to a specific Route or Gateway must be placed on the
// Route(s) using backends configured by this BackendPolicy.
type BackendPolicyStatus struct {
// Conditions describe the current conditions of the BackendPolicy.
//
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=8
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions"`
}

// BackendPolicyConditionType is a type of condition associated with a
Expand Down
37 changes: 28 additions & 9 deletions apis/v1alpha1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,25 @@ import (
// This ensures that a GatewayClass associated with a Gateway(s) is not
// deleted while in use.
type Gateway struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

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

// Status defines the current state of Gateway.
//
// +optional
// +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"`
Expand All @@ -61,6 +68,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"`
Expand Down Expand Up @@ -293,8 +301,9 @@ type TLSOverridePolicy struct {
//
// Support: Core
//
// +optional
// +kubebuilder:default=Deny
Certificate TLSRouteOverrideType `json:"certificate"`
Certificate TLSRouteOverrideType `json:"certificate,omitempty"`
}

// GatewayTLSConfig describes a TLS configuration.
Expand All @@ -319,6 +328,7 @@ type GatewayTLSConfig struct {
//
// Support: Core
//
// +optional
// +kubebuilder:default=Terminate
Mode TLSModeType `json:"mode,omitempty"`

Expand Down Expand Up @@ -349,6 +359,7 @@ type GatewayTLSConfig struct {
//
// Support: Core
//
// +optional
// +kubebuilder:default={certificate:Deny}
RouteOverride TLSOverridePolicy `json:"routeOverride,omitempty"`

Expand All @@ -363,7 +374,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.
Expand Down Expand Up @@ -391,8 +402,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.
Expand All @@ -418,10 +431,11 @@ type RouteBindingSelector struct {
//
// Support: Core
//
// +optional
// +kubebuilder:default=networking.x-k8s.io
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Group string `json:"group,omitempty"`
Group *string `json:"group,omitempty"`
// Kind is the kind of the route resource to select.
//
// Kind MUST correspond to kinds of routes that are compatible with the
Expand All @@ -436,8 +450,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 (
Expand All @@ -462,6 +476,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,
Expand All @@ -480,6 +497,7 @@ type GatewayAddress struct {
//
// Support: Extended
//
// +optional
// +kubebuilder:default=IPAddress
Type AddressType `json:"type,omitempty"`

Expand Down Expand Up @@ -540,7 +558,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.
//
Expand All @@ -554,6 +572,7 @@ type GatewayStatus struct {
// * "Scheduled"
// * "Ready"
//
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
Expand Down
17 changes: 11 additions & 6 deletions apis/v1alpha1/gatewayclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ import (
// for creating Gateway resources.
//
// GatewayClass is a Cluster level resource.
//
// Support: Core.
type GatewayClass struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec for this GatewayClass.
// Spec defines the desired state of GatewayClass.
//
// +optional
Spec GatewayClassSpec `json:"spec,omitempty"`
// Status of the GatewayClass.

// Status defines the current state of GatewayClass.
//
// +optional
// +kubebuilder:default={conditions: {{type: "Admitted", status: "False", message: "Waiting for controller", reason: "Waiting", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status GatewayClassStatus `json:"status,omitempty"`
}
Expand Down Expand Up @@ -77,7 +81,7 @@ type GatewayClassSpec struct {
// Support: Custom
//
// +optional
ParametersRef *LocalObjectReference `json:"parametersRef,omitempty"`
ParametersRef LocalObjectReference `json:"parametersRef,omitempty"`
}

// GatewayClassConditionType is the type of status conditions. This
Expand Down Expand Up @@ -115,6 +119,7 @@ type GatewayClassStatus struct {
// Conditions is the current status from the controller for
// this GatewayClass.
//
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
Expand Down
Loading

0 comments on commit 185a2fa

Please sign in to comment.