Skip to content

Commit

Permalink
chore: add KIC API reference markers
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Oct 7, 2024
1 parent 1a09bf1 commit 36a8c40
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@ create a new tag and push it to the repository.
|-----------------------------|------------|---------------------------------------------------------------------------------------------------------------|
| `+apireference:kgo:exclude` | Fields | Any field annotated with this marker will be excluded from the [KGO's generated CRDs reference][kgo-crd-ref]. |
| `+apireference:kgo:include` | Types | Any type annotated with this marker will be included in the [KGO's generated CRDs reference][kgo-crd-ref]. |
| `+apireference:kic:exclude` | Fields | Any type annotated with this marker will be excluded from the [KIC's generated CRDs reference][kic-crd-ref]. |
| `+apireference:kic:include` | Types | Any type annotated with this marker will be included in the [KIC's generated CRDs reference][kic-crd-ref]. |

[kgo-crd-ref]: https://github.com/Kong/gateway-operator/blob/main/docs/api-reference.md
[kic-crd-ref]: https://github.com/kong/kubernetes-ingress-controller/blob/main/docs/api-reference.md
2 changes: 2 additions & 0 deletions api/configuration/v1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package v1
// ConditionType is a type of condition associated with an object.
// This type should be used with the object's Status.Conditions field.
// +apireference:kgo:include
// +apireference:kic:include
type ConditionType string

// ConditionReason defines the set of reasons that explain why a particular
// condition type has been raised.
// +apireference:kgo:include
// +apireference:kic:include
type ConditionReason string

const (
Expand Down
6 changes: 6 additions & 0 deletions api/configuration/v1/configsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1

// ConfigSource is a wrapper around SecretValueFromSource.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type ConfigSource struct {
// Specifies a name and a key of a secret to refer to. The namespace is implicitly set to the one of referring object.
SecretValue SecretValueFromSource `json:"secretKeyRef"`
Expand All @@ -11,6 +12,7 @@ type ConfigSource struct {
// It is an equivalent of the following patch:
// `{"op": "add", "path": {.Path}, "value": {.ComputedValueFrom}}`.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type ConfigPatch struct {
// Path is the JSON-Pointer value (RFC6901) that references a location within the target configuration.
Path string `json:"path"`
Expand All @@ -20,6 +22,7 @@ type ConfigPatch struct {

// NamespacedConfigSource is a wrapper around NamespacedSecretValueFromSource.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type NamespacedConfigSource struct {
// Specifies a name, a namespace, and a key of a secret to refer to.
SecretValue NamespacedSecretValueFromSource `json:"secretKeyRef"`
Expand All @@ -28,6 +31,7 @@ type NamespacedConfigSource struct {
// NamespacedConfigPatch is a JSON patch to add values from secrets to KongClusterPlugin
// to the generated configuration of plugin in Kong.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type NamespacedConfigPatch struct {
// Path is the JSON path to add the patch.
Path string `json:"path"`
Expand All @@ -37,6 +41,7 @@ type NamespacedConfigPatch struct {

// SecretValueFromSource represents the source of a secret value.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type SecretValueFromSource struct {
// The secret containing the key.
Secret string `json:"name"`
Expand All @@ -46,6 +51,7 @@ type SecretValueFromSource struct {

// NamespacedSecretValueFromSource represents the source of a secret value specifying the secret namespace.
// +kubebuilder:object:generate=true
// +apireference:kic:include
type NamespacedSecretValueFromSource struct {
// The namespace containing the secret.
Namespace string `json:"namespace"`
Expand Down
2 changes: 2 additions & 0 deletions api/configuration/v1/kongclusterplugin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
// +kubebuilder:validation:XValidation:rule="self.plugin == oldSelf.plugin", message="The plugin field is immutable"

// KongClusterPlugin is the Schema for the kongclusterplugins API.
// +apireference:kic:include
type KongClusterPlugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -110,6 +111,7 @@ type KongClusterPluginList struct {
}

// KongClusterPluginStatus represents the current status of the KongClusterPlugin resource.
// +apireference:kic:include
type KongClusterPluginStatus struct {
// Conditions describe the current conditions of the KongClusterPluginStatus.
//
Expand Down
6 changes: 6 additions & 0 deletions api/configuration/v1/kongconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
// +kubebuilder:validation:XValidation:rule="!has(self.spec.controlPlaneRef.konnectNamespacedRef) ? true : !has(self.spec.controlPlaneRef.konnectNamespacedRef.__namespace__)", message="spec.controlPlaneRef cannot specify namespace for namespaced resource"
// +kubebuilder:validation:XValidation:rule="(!has(self.status) || !self.status.conditions.exists(c, c.type == 'Programmed' && c.status == 'True')) ? true : oldSelf.spec.controlPlaneRef == self.spec.controlPlaneRef", message="spec.controlPlaneRef is immutable when an entity is already Programmed"
// +apireference:kgo:include
// +apireference:kic:include
type KongConsumer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -69,6 +70,7 @@ type KongConsumer struct {

// KongConsumerSpec defines the specification of the KongConsumer.
// +apireference:kgo:include
// +apireference:kic:include
type KongConsumerSpec struct {
// ControlPlaneRef is a reference to a ControlPlane this Consumer is associated with.
// +optional
Expand All @@ -78,16 +80,20 @@ type KongConsumerSpec struct {
// KongConsumerList contains a list of KongConsumer.
// +kubebuilder:object:root=true
// +apireference:kgo:include
// +apireference:kic:include
type KongConsumerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KongConsumer `json:"items"`
}

// KongConsumerStatus represents the current status of the KongConsumer resource.
// +apireference:kgo:include
// +apireference:kic:include
type KongConsumerStatus struct {
// Konnect contains the Konnect entity status.
// +optional
// +apireference:kic:exclude
Konnect *konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"`

// Conditions describe the current conditions of the KongConsumer.
Expand Down
5 changes: 5 additions & 0 deletions api/configuration/v1/kongingress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
// +kubebuilder:validation:XValidation:rule="!has(self.route)", message="'route' field is no longer supported, use Ingress' annotations instead"

// KongIngress is the Schema for the kongingresses API.
// +apireference:kic:include
type KongIngress struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -53,6 +54,7 @@ type KongIngress struct {
// +kubebuilder:object:root=true

// KongIngressList contains a list of KongIngress.
// +apireference:kic:include
type KongIngressList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -62,6 +64,7 @@ type KongIngressList struct {
// KongIngressService contains KongIngress service configuration.
// It contains the subset of go-kong.kong.Service fields supported by kongstate.Service.overrideByKongIngress.
// Deprecated: use Service's annotations instead.
// +apireference:kic:include
type KongIngressService struct {
// The protocol used to communicate with the upstream.
// Deprecated: use Service's "konghq.com/protocol" annotation instead.
Expand Down Expand Up @@ -99,6 +102,7 @@ type KongIngressService struct {
// KongIngressRoute contains KongIngress route configuration.
// It contains the subset of `go-kong.kong.Route` fields supported by `kongstate.Route.overrideByKongIngress`.
// Deprecated: use Ingress' annotations instead.
// +apireference:kic:include
type KongIngressRoute struct {
// Methods is a list of HTTP methods that match this Route.
// Deprecated: use Ingress' "konghq.com/methods" annotation instead.
Expand Down Expand Up @@ -157,6 +161,7 @@ type KongIngressRoute struct {

// KongIngressUpstream contains KongIngress upstream configuration.
// It contains the subset of `go-kong.kong.Upstream` fields supported by `kongstate.Upstream.overrideByKongIngress`.
// +apireference:kic:include
type KongIngressUpstream struct {
// HostHeader is The hostname to be used as Host header
// when proxying requests through Kong.
Expand Down
3 changes: 3 additions & 0 deletions api/configuration/v1/kongplugin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
// +kubebuilder:validation:XValidation:rule="!(has(self.configFrom) && has(self.configPatches))", message="Using both configFrom and configPatches fields is not allowed."
// +kubebuilder:validation:XValidation:rule="self.plugin == oldSelf.plugin", message="The plugin field is immutable"
// +apireference:kgo:include
// +apireference:kic:include
type KongPlugin struct {
metav1.TypeMeta `json:",inline"`
// Setting a `global` label to `true` will apply the plugin to every request proxied by the Kong.
Expand Down Expand Up @@ -108,6 +109,7 @@ type KongPlugin struct {
// KongPluginList contains a list of KongPlugin.
// +kubebuilder:object:root=true
// +apireference:kgo:include
// +apireference:kic:include
type KongPluginList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -116,6 +118,7 @@ type KongPluginList struct {

// KongPluginStatus represents the current status of the KongPlugin resource.
// +apireference:kgo:include
// +apireference:kic:include
type KongPluginStatus struct {
// Conditions describe the current conditions of the KongPluginStatus.
//
Expand Down
1 change: 1 addition & 0 deletions api/configuration/v1/kongprotocol_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package v1
// +kubebuilder:validation:Enum=http;https;grpc;grpcs;tcp;tls;udp
// +kubebuilder:object:generate=true
// +apireference:kgo:include
// +apireference:kic:include
type KongProtocol string

// KongProtocolsToStrings converts a slice of KongProtocol to plain strings.
Expand Down
3 changes: 3 additions & 0 deletions api/configuration/v1alpha1/ingress_class_param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
// +kubebuilder:object:root=true

// IngressClassParametersList contains a list of IngressClassParameters.
// +apireference:kic:include
type IngressClassParametersList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -42,6 +43,7 @@ type IngressClassParametersList struct {
// +kubebuilder:resource:path=ingressclassparameterses

// IngressClassParameters is the Schema for the IngressClassParameters API.
// +apireference:kic:include
type IngressClassParameters struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -51,6 +53,7 @@ type IngressClassParameters struct {
}

// IngressClassParametersSpec defines the desired state of IngressClassParameters.
// +apireference:kic:include
type IngressClassParametersSpec struct {
// Offload load-balancing to kube-proxy or sidecar.
// +kubebuilder:default:=false
Expand Down
3 changes: 3 additions & 0 deletions api/configuration/v1alpha1/kong_license_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ type Namespace string
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +apireference:kgo:include
// +apireference:kic:include
type ObjectName string

// ControllerReference is a reference to a controller that reconciles the KongLicense.
// +apireference:kgo:include
// +apireference:kic:include
type ControllerReference struct {
// Group is the group of referent.
// It should be empty if the referent is in "core" group (like pod).
Expand All @@ -104,6 +106,7 @@ type ControllerReference struct {
// KongLicenseList contains a list of KongLicense.
// +kubebuilder:object:root=true
// +apireference:kgo:include
// +apireference:kic:include
type KongLicenseList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/configuration/v1alpha1/kong_vault_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.spec.controlPlaneRef) || has(self.spec.controlPlaneRef)", message="controlPlaneRef is required once set"
// +kubebuilder:validation:XValidation:rule="(!has(self.status) || !self.status.conditions.exists(c, c.type == 'Programmed' && c.status == 'True')) ? true : oldSelf.spec.controlPlaneRef == self.spec.controlPlaneRef", message="spec.controlPlaneRef is immutable when an entity is already Programmed"
// +apireference:kgo:include
// +apireference:kic:include
type KongVault struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -57,6 +58,7 @@ type KongVault struct {

// KongVaultSpec defines specification of a custom Kong vault.
// +apireference:kgo:include
// +apireference:kic:include
type KongVaultSpec struct {
// Backend is the type of the backend storing the secrets in the vault.
// The supported backends of Kong is listed here:
Expand All @@ -80,9 +82,11 @@ type KongVaultSpec struct {

// KongVaultStatus represents the current status of the KongVault resource.
// +apireference:kgo:include
// +apireference:kic:include
type KongVaultStatus struct {
// Konnect contains the Konnect entity status.
// +optional
// +apireference:kic:exclude
Konnect *konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"`

// Conditions describe the current conditions of the KongVaultStatus.
Expand All @@ -101,6 +105,7 @@ type KongVaultStatus struct {
// KongVaultList contains a list of KongVault.
// +kubebuilder:object:root=true
// +apireference:kgo:include
// +apireference:kic:include
type KongVaultList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions api/configuration/v1beta1/ingress_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1beta1
// UDPIngressRule represents a rule to apply against incoming requests
// wherein no Host matching is available for request routing, only the port
// is used to match requests.
// +apireference:kic:include
type UDPIngressRule struct {
// Port indicates the port for the Kong proxy to accept incoming traffic
// on, which will then be routed to the service Backend.
Expand All @@ -18,6 +19,7 @@ type UDPIngressRule struct {

// IngressRule represents a rule to apply against incoming requests.
// Matching is performed based on an (optional) SNI and port.
// +apireference:kic:include
type IngressRule struct {
// Host is the fully qualified domain name of a network host, as defined
// by RFC 3986.
Expand Down Expand Up @@ -45,6 +47,7 @@ type IngressRule struct {
}

// IngressBackend describes all endpoints for a given service and port.
// +apireference:kic:include
type IngressBackend struct {
// Specifies the name of the referenced service.
// +kubebuilder:validation:Required
Expand Down
13 changes: 9 additions & 4 deletions api/configuration/v1beta1/kongconsumergroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
)

// KongConsumerGroup is the Schema for the kongconsumergroups API.
//
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
Expand All @@ -34,8 +36,8 @@ import (
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.spec.controlPlaneRef) || has(self.spec.controlPlaneRef)", message="controlPlaneRef is required once set"
// +kubebuilder:validation:XValidation:rule="!has(self.spec.controlPlaneRef.konnectNamespacedRef) ? true : !has(self.spec.controlPlaneRef.konnectNamespacedRef.__namespace__)", message="spec.controlPlaneRef cannot specify namespace for namespaced resource"
// +kubebuilder:validation:XValidation:rule="(!has(self.status) || !self.status.conditions.exists(c, c.type == 'Programmed' && c.status == 'True')) ? true : oldSelf.spec.controlPlaneRef == self.spec.controlPlaneRef", message="spec.controlPlaneRef is immutable when an entity is already Programmed"

// KongConsumerGroup is the Schema for the kongconsumergroups API.
// +apireference:kgo:include
// +apireference:kic:include
type KongConsumerGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -48,6 +50,7 @@ type KongConsumerGroup struct {
}

// KongConsumerGroupSpec defines the desired state of KongConsumerGroup.
// +apireference:kic:include
type KongConsumerGroupSpec struct {
// Name is the name of the ConsumerGroup in Kong.
Name string `json:"name,omitempty"`
Expand All @@ -57,19 +60,21 @@ type KongConsumerGroupSpec struct {
ControlPlaneRef *configurationv1alpha1.ControlPlaneRef `json:"controlPlaneRef,omitempty"`
}

// +kubebuilder:object:root=true

// KongConsumerGroupList contains a list of KongConsumerGroups.
// +kubebuilder:object:root=true
// +apireference:kic:include
type KongConsumerGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KongConsumerGroup `json:"items"`
}

// KongConsumerGroupStatus represents the current status of the KongConsumerGroup resource.
// +apireference:kic:include
type KongConsumerGroupStatus struct {
// Konnect contains the Konnect entity status.
// +optional
// +apireference:kic:exclude
Konnect *konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"`

// Conditions describe the current conditions of the KongConsumerGroup.
Expand Down
Loading

0 comments on commit 36a8c40

Please sign in to comment.