Skip to content

Commit

Permalink
chore: adapt apidocs-gen script to use kconf definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Oct 4, 2024
1 parent 67a3ef9 commit 3de6fb9
Show file tree
Hide file tree
Showing 20 changed files with 2,069 additions and 56 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ machine against the cluster that you have configured via your `KUBECONFIG`.

### Adding new CRDs

Whenever you add a new CRD ensure that it is included in project's [`PROJECT`](./PROJECT) file.

This is necessary for creation of a bundle for external hubs like [Operator Hub's community operators][community-operators].
Whenever you add a new CRD:
- Ensure that it is included in project's [`PROJECT`](./PROJECT) file. This is necessary for creation of
a bundle for external hubs like [Operator Hub's community operators][community-operators].
- Annotate the CRD and any new type it depends on with the right markers to make sure it will be included
in the generated documentation. See [available markers][available-markers].

[community-operators]: https://github.com/k8s-operatorhub/community-operators/
[available-markers]: https://github.com/Kong/kubernetes-configuration/blob/main/README.md#available-custom-markers

## Seeking Help

Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/aigateway_cloud_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package v1alpha1

// AICloudProviderName indicates the unique name of a supported AI cloud
// provider.
// +apireference:kgo:include
type AICloudProviderName string

const (
Expand Down Expand Up @@ -36,6 +37,7 @@ const (

// AICloudProvider is the organization that provides API access to Large Language
// Models (LLMs).
// +apireference:kgo:include
type AICloudProvider struct {
// Name is the unique name of an LLM provider.
//
Expand All @@ -46,6 +48,7 @@ type AICloudProvider struct {

// AICloudProviderAPITokenRef is an reference to another object which contains
// the API token for an AI cloud provider.
// +apireference:kgo:include
type AICloudProviderAPITokenRef struct {
// Name is the name of the reference object.
//
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/aigateway_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// -----------------------------------------------------------------------------

// AIGatewayEndpoint is a network endpoint for accessing an AIGateway.
// +apireference:kgo:include
type AIGatewayEndpoint struct {
// NetworkAccessHint is a hint to the user about what kind of network access
// is expected for the reachability of this endpoint.
Expand Down Expand Up @@ -49,6 +50,7 @@ type AIGatewayEndpoint struct {
// This isn't meant to reflect knowledge of any specific network by name, which
// is why it includes "hint" in the name. It's meant to be a hint to the user
// such as "internet-accessible", "internal-only".
// +apireference:kgo:include
type EndpointNetworkAccessHint string

const (
Expand All @@ -59,6 +61,7 @@ const (

// AIGatewayConsumerRef indicates the Secret resource containing the credentials
// for the Kong consumer.
// +apireference:kgo:include
type AIGatewayConsumerRef struct {
// Name is the name of the reference object.
//
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/aigateway_llm_prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package v1alpha1
// For example, you might want to provide a "system" role and tell the LLM
// something like "you are a helpful assistant who responds in the style of
// Sherlock Holmes".
// +apireference:kgo:include
type LLMPrompt struct {
// Content is the prompt text sent for inference.
//
Expand All @@ -36,6 +37,7 @@ type LLMPrompt struct {

// LLMPromptParams contains parameters that can be used to control the behavior
// of a large language model (LLM) when generating text based on a prompt.
// +apireference:kgo:include
type LLMPromptParams struct {
// Temperature controls the randomness of predictions by scaling the logits
// before applying softmax. A lower temperature (e.g., 0.0 to 0.7) makes
Expand Down Expand Up @@ -88,6 +90,7 @@ type LLMPromptParams struct {
// -----------------------------------------------------------------------------

// LLMPromptRole indicates the role of a prompt for a large language model (LLM).
// +apireference:kgo:include
type LLMPromptRole string

const (
Expand All @@ -104,6 +107,7 @@ const (

// LLMPromptType indicates the type of prompt to be used for a large
// language model (LLM).
// +apireference:kgo:include
type LLMPromptType string

const (
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/aigateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".status.endpoint",description="The URL endpoint for the AIGateway"
// +apireference:kgo:include
type AIGateway struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -67,6 +68,7 @@ type AIGateway struct {
// AIGatewayList contains a list of AIGateways.
//
// +kubebuilder:object:root=true
// +apireference:kgo:include
type AIGatewayList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -80,6 +82,7 @@ type AIGatewayList struct {
// -----------------------------------------------------------------------------

// AIGatewaySpec defines the desired state of an AIGateway.
// +apireference:kgo:include
type AIGatewaySpec struct {
// GatewayClassName is the name of the GatewayClass which is responsible for
// the AIGateway.
Expand Down Expand Up @@ -139,6 +142,7 @@ type AIGatewaySpec struct {
// LargeLanguageModels is a list of Large Language Models (LLM) hosted in
// various ways (cloud hosted, self hosted, e.t.c.) which the AIGateway should
// serve and manage traffic for.
// +apireference:kgo:include
type LargeLanguageModels struct {
// CloudHosted configures LLMs hosted and served by cloud providers.
//
Expand All @@ -155,6 +159,7 @@ type LargeLanguageModels struct {
// CloudHostedLargeLanguageModel is the configuration for Large Language Models
// (LLM) hosted by a known and supported AI cloud provider (e.g. OpenAI, Cohere,
// Azure, e.t.c.).
// +apireference:kgo:include
type CloudHostedLargeLanguageModel struct {
// Identifier is the unique name which identifies the LLM. This will be used
// as part of the requests made to an AIGateway endpoint. For instance: if
Expand Down Expand Up @@ -223,6 +228,7 @@ type CloudHostedLargeLanguageModel struct {
// -----------------------------------------------------------------------------

// AIGatewayStatus defines the observed state of AIGateway.
// +apireference:kgo:include
type AIGatewayStatus struct {
// Endpoints are collections of the URL, credentials and metadata needed in
// order to access models served by the AIGateway for inference.
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/dataplane_konnect_extension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {
// If a DataPlane successfully refers a DataPlaneKonnectExtension, the DataPlane
// deployment spec gets customized to include the konnect-related configuration.
// +kubebuilder:validation:XValidation:rule="oldSelf.spec.controlPlaneRef == self.spec.controlPlaneRef", message="spec.controlPlaneRef is immutable."
// +apireference:kgo:include
type DataPlaneKonnectExtension struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -47,13 +48,15 @@ type DataPlaneKonnectExtension struct {
// +kubebuilder:object:root=true

// DataPlaneKonnectExtensionList contains a list of DataPlaneKonnectExtension.
// +apireference:kgo:include
type DataPlaneKonnectExtensionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DataPlaneKonnectExtension `json:"items"`
}

// DataPlaneKonnectExtensionSpec defines the desired state of DataPlaneKonnectExtension.
// +apireference:kgo:include
type DataPlaneKonnectExtensionSpec struct {
// ControlPlaneRef is a reference to a ControlPlane this DataPlaneKonnectExtension is associated with.
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -89,20 +92,23 @@ type DataPlaneKonnectExtensionSpec struct {
}

// KonnectControlPlaneAPIAuthConfiguration contains the configuration to authenticate with Konnect API ControlPlane.
// +apireference:kgo:include
type KonnectControlPlaneAPIAuthConfiguration struct {
// ClusterCertificateSecretName is a name of the Secret containing the Konnect Control Plane's cluster certificate.
// +kubebuilder:validation:Required
ClusterCertificateSecretName ClusterCertificateSecretRef `json:"clusterCertificateSecretRef"`
}

// ClusterCertificateSecretRef contains the reference to the Secret containing the Konnect Control Plane's cluster certificate.
// +apireference:kgo:include
type ClusterCertificateSecretRef struct {
// Name is the name of the Secret containing the Konnect Control Plane's cluster certificate.
// +kubebuilder:validation:Required
Name string `json:"name"`
}

// DataPlaneKonnectExtensionStatus defines the observed state of DataPlaneKonnectExtension.
// +apireference:kgo:include
type DataPlaneKonnectExtensionStatus struct {
// DataPlaneRefs is the array of DataPlane references this is associated with.
// A new reference is set by the operator when this extension is associated with
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/dataplane_metrics_extension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
//
// NOTE: This is an enterprise feature. In order to use it you need to use
// the EE version of Kong Gateway Operator with a valid license.
// +apireference:kgo:include
type DataPlaneMetricsExtension struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -53,13 +54,15 @@ type DataPlaneMetricsExtension struct {
// +kubebuilder:object:root=true

// DataPlaneMetricsExtensionList contains a list of DataPlaneMetricsExtension.
// +apireference:kgo:include
type DataPlaneMetricsExtensionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DataPlaneMetricsExtension `json:"items"`
}

// DataPlaneMetricsExtensionSpec defines the spec for the DataPlaneMetricsExtension.
// +apireference:kgo:include
type DataPlaneMetricsExtensionSpec struct {
// ServiceSelector holds the service selector specifying the services
// for which metrics should be collected.
Expand All @@ -74,6 +77,7 @@ type DataPlaneMetricsExtensionSpec struct {
}

// MetricsConfig holds the configuration for the DataPlane metrics.
// +apireference:kgo:include
type MetricsConfig struct {
// Latency indicates whether latency metrics are enabled for the DataPlane.
// This translates into deployed instances having `latency_metrics` option set
Expand Down Expand Up @@ -109,6 +113,7 @@ type MetricsConfig struct {
}

// DataPlaneMetricsExtensionStatus defines the status of the DataPlaneMetricsExtension.
// +apireference:kgo:include
type DataPlaneMetricsExtensionStatus struct {
// ControlPlaneRef is a reference to the ControlPlane that this is associated with.
// This field is set by the operator when this extension is associated with
Expand All @@ -121,6 +126,7 @@ type DataPlaneMetricsExtensionStatus struct {
}

// ServiceSelector holds the service selector specification.
// +apireference:kgo:include
type ServiceSelector struct {
// MatchNames holds the list of Services names to match.
//
Expand All @@ -131,6 +137,7 @@ type ServiceSelector struct {
}

// ServiceSelectorEntry holds the name of a service to match.
// +apireference:kgo:include
type ServiceSelectorEntry struct {
// Name is the name of the service to match.
//
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/extensionref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

// ExtensionRef corresponds to another resource in the Kubernetes cluster which
// defines extended behavior for a resource (e.g. ControlPlane).
// +apireference:kgo:include
type ExtensionRef struct {
// Group is the group of the extension resource.
// +kubebuilder:validation:Optional
Expand All @@ -32,6 +33,7 @@ type ExtensionRef struct {
}

// NamespacedRef is a reference to a namespaced resource.
// +apireference:kgo:include
type NamespacedRef struct {
// Name is the name of the referred resource.
//
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "gateway-operator.konghq.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}

Expand Down
36 changes: 21 additions & 15 deletions api/v1alpha1/kongplugin_installation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ func init() {
SchemeBuilder.Register(&KongPluginInstallation{}, &KongPluginInstallationList{})
}

//+genclient
//+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=kpi,categories=kong;all
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Accepted",description="The Resource is accepted",type=string,JSONPath=`.status.conditions[?(@.type=='Accepted')].status`

// KongPluginInstallation allows using a custom Kong Plugin distributed as a container image available in a registry.
// Such a plugin can be associated with GatewayConfiguration or DataPlane to be available for particular Kong Gateway
// and configured with KongPlugin CRD.
//
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=kpi,categories=kong;all
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Accepted",description="The Resource is accepted",type=string,JSONPath=`.status.conditions[?(@.type=='Accepted')].status`
// +apireference:kgo:include
type KongPluginInstallation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -44,44 +45,47 @@ type KongPluginInstallation struct {
Status KongPluginInstallationStatus `json:"status,omitempty"`
}

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

// KongPluginInstallationList contains a list of KongPluginInstallation.
// +apireference:kgo:include
type KongPluginInstallationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KongPluginInstallation `json:"items"`
}

// KongPluginInstallationSpec provides the information necessary to retrieve and install a Kong custom plugin.
// +apireference:kgo:include
type KongPluginInstallationSpec struct {

// The image is an OCI image URL for a packaged custom Kong plugin.
//
//+kubebuilder:validation:Required
// +kubebuilder:validation:Required
Image string `json:"image"`

// ImagePullSecretRef is a reference to a Kubernetes Secret containing credentials necessary to pull the OCI image
// in Image. It must follow the format in https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry.
// It is optional. If the image is public, omit this field.
//
//+optional
// +optional
ImagePullSecretRef *gatewayv1.SecretObjectReference `json:"imagePullSecretRef,omitempty"`
}

// KongPluginInstallationStatus defines the observed state of KongPluginInstallation.
// +apireference:kgo:include
type KongPluginInstallationStatus struct {
// Conditions describe the current conditions of this KongPluginInstallation.
//
//+listType=map
//+listMapKey=type
//+kubebuilder:validation:MaxItems=8
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
Conditions []metav1.Condition `json:"conditions,omitempty"`

// UnderlyingConfigMapName is the name of the ConfigMap that contains the plugin's content.
// It is set when the plugin is successfully fetched and unpacked.
//
//+optional
// +optional
UnderlyingConfigMapName string `json:"underlyingConfigMapName,omitempty"`
}

Expand All @@ -90,9 +94,11 @@ type KongPluginInstallationStatus struct {

// KongPluginInstallationConditionType is the type for Conditions in a KongPluginInstallation's
// Status.Conditions array.
// +apireference:kgo:include
type KongPluginInstallationConditionType string

// KongPluginInstallationConditionReason is a reason for the KongPluginInstallation condition's last transition.
// +apireference:kgo:include
type KongPluginInstallationConditionReason string

const (
Expand Down
Loading

0 comments on commit 3de6fb9

Please sign in to comment.