Skip to content
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

Improve API reference docs #667

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// Package v1alpha1 contains API Schema definitions for the hypershift.openshift.io v1alpha1 API group
/*
Package v1alpha1 contains the HyperShift API.

The HyperShift API enables creating and managing lightweight, flexible, heterogeneous
OpenShift clusters at scale.

HyperShift clusters are deployed in a topology which isolates the "control plane"
(e.g. etcd, the API server, controller manager, etc.) from the "data plane" (e.g.
worker nodes and their kubelets, and the infrastructure on which they run). This
enables "hosted control plane as a service" use cases.
*/
// +kubebuilder:object:generate=true
// +groupName=hypershift.openshift.io
package v1alpha1
12 changes: 11 additions & 1 deletion api/v1alpha1/hosted_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,21 @@ type HostedControlPlaneSpec struct {
SecretEncryption *SecretEncryptionSpec `json:"secretEncryption,omitempty"`
}

// AvailabilityPolicy specifies a high level availability policy for components.
type AvailabilityPolicy string

const (
// HighlyAvailable means components should be resilient to problems across fault
// boundaries as defined by the component to which the policy is attached. This
// usually means running critical workloads with 3 replicas and with little or
// no toleration of disruption of the component.
HighlyAvailable AvailabilityPolicy = "HighlyAvailable"
SingleReplica AvailabilityPolicy = "SingleReplica"

// SingleReplica means components are not expected to be resilient to problems
// across most fault boundaries associated with high availability. This usually
// means running critical workloads with just 1 replica and with toleration of
// full disruption of the component.
SingleReplica AvailabilityPolicy = "SingleReplica"
)

type KubeconfigSecretRef struct {
Expand Down
17 changes: 14 additions & 3 deletions api/v1alpha1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ type HostedClusterSpec struct {
// TODO (alberto): include Ignition endpoint here.
Services []ServicePublishingStrategyMapping `json:"services"`

// ControllerAvailabilityPolicy specifies whether to run control plane controllers in HA mode
// ControllerAvailabilityPolicy specifies an availability policy to apply
// to critical control plane components.
// Defaults to SingleReplica when not set.
// +optional
ControllerAvailabilityPolicy AvailabilityPolicy `json:"controllerAvailabilityPolicy,omitempty"`
Expand Down Expand Up @@ -841,6 +842,14 @@ type ClusterConfiguration struct {
Items []runtime.RawExtension `json:"items,omitempty"`
}

// +genclient

// HostedCluster is the primary representation of a HyperShift cluster and encapsulates
// the control plane and common data plane configuration. Creating a HostedCluster
// results in a fully functional OpenShift control plane with no attached nodes.
// To support workloads (e.g. pods), a HostedCluster may have one or more associated
// NodePool resources.
//
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hostedclusters,shortName=hc;hcs,scope=Namespaced
// +kubebuilder:storageversion
Expand All @@ -850,12 +859,14 @@ type ClusterConfiguration struct {
// +kubebuilder:printcolumn:name="Progress",type="string",JSONPath=".status.version.history[?(@.state!=\"\")].state",description="Progress"
// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type==\"Available\")].status",description="Available"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type==\"Available\")].reason",description="Reason"
// HostedCluster is the Schema for the hostedclusters API
type HostedCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec HostedClusterSpec `json:"spec,omitempty"`
// Spec is the desired behavior of the HostedCluster.
Spec HostedClusterSpec `json:"spec,omitempty"`

// Status is the latest observed status of the HostedCluster.
Status HostedClusterStatus `json:"status,omitempty"`
}

Expand Down
12 changes: 10 additions & 2 deletions api/v1alpha1/nodepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func init() {
SchemeBuilder.Register(&NodePoolList{})
}

// NodePool defines the desired state of NodePool
// +genclient

// NodePool is a scalable set of worker nodes attached to a HostedCluster. NodePool
// machine architectures are uniform within a given pool, and are independent of
// the control plane’s underlying machine architecture.
//
// +kubebuilder:resource:path=nodepools,shortName=np;nps,scope=Namespaced
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
Expand All @@ -47,7 +52,10 @@ type NodePool struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NodePoolSpec `json:"spec,omitempty"`
// Spec is the desired behavior of the NodePool.
Spec NodePoolSpec `json:"spec,omitempty"`

// Status is the most recently observed status of the NodePool.
Status NodePoolStatus `json:"status,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: HostedCluster is the Schema for the hostedclusters API
description: HostedCluster is the primary representation of a HyperShift cluster
and encapsulates the control plane and common data plane configuration.
Creating a HostedCluster results in a fully functional OpenShift control
plane with no attached nodes. To support workloads (e.g. pods), a HostedCluster
may have one or more associated NodePool resources.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -58,7 +62,7 @@ spec:
metadata:
type: object
spec:
description: HostedClusterSpec defines the desired state of HostedCluster
description: Spec is the desired behavior of the HostedCluster.
properties:
auditWebhook:
description: AuditWebhook contains metadata for configuring an audit
Expand Down Expand Up @@ -144,9 +148,9 @@ spec:
type: array
type: object
controllerAvailabilityPolicy:
description: ControllerAvailabilityPolicy specifies whether to run
control plane controllers in HA mode Defaults to SingleReplica when
not set.
description: ControllerAvailabilityPolicy specifies an availability
policy to apply to critical control plane components. Defaults to
SingleReplica when not set.
type: string
dns:
description: DNS configuration for the cluster
Expand Down Expand Up @@ -813,7 +817,7 @@ spec:
- sshKey
type: object
status:
description: HostedClusterStatus defines the observed state of HostedCluster
description: Status is the latest observed status of the HostedCluster.
properties:
conditions:
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: NodePool defines the desired state of NodePool
description: NodePool is a scalable set of worker nodes attached to a HostedCluster.
NodePool machine architectures are uniform within a given pool, and are
independent of the control plane’s underlying machine architecture.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -66,7 +68,7 @@ spec:
metadata:
type: object
spec:
description: NodePoolSpec defines the desired state of NodePool
description: Spec is the desired behavior of the NodePool.
properties:
autoScaling:
properties:
Expand Down Expand Up @@ -325,7 +327,7 @@ spec:
- release
type: object
status:
description: NodePoolStatus defines the observed state of NodePool
description: Status is the most recently observed status of the NodePool.
properties:
conditions:
items:
Expand Down
32 changes: 18 additions & 14 deletions docs/api-doc-gen/config.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{
"hideMemberFields": [
"TypeMeta"
"TypeMeta"
],
"hideTypePatterns": [
"ParseError$",
"List$"
"ParseError$",
"List$",
"HostedControlPlane*$",
"KubeconfigSecretRef",
"APIEndpoint",
"AWSEndpointService*"
],
"externalPackages": [
{
"typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Duration$",
"docsURLTemplate": "https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Duration"
},
{
"typeMatchPrefix": "^k8s\\.io/(api|apimachinery|apiextensions-apiserver/pkg/apis)/",
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
}
{
"typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Duration$",
"docsURLTemplate": "https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Duration"
},
{
"typeMatchPrefix": "^k8s\\.io/(api|apimachinery|apiextensions-apiserver/pkg/apis)/",
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
}
],
"typeDisplayNamePrefixOverrides": {
"k8s.io/api/": "Kubernetes ",
"k8s.io/apimachinery/pkg/apis/": "Kubernetes ",
"k8s.io/apiextensions-apiserver/pkg/apis/": "Kubernetes "
"k8s.io/api/": "Kubernetes ",
"k8s.io/apimachinery/pkg/apis/": "Kubernetes ",
"k8s.io/apiextensions-apiserver/pkg/apis/": "Kubernetes "
},
"markdownDisabled": false
}
11 changes: 0 additions & 11 deletions docs/api-doc-gen/templates/pkg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ title: API Reference
{{ end }}
{{ end }}

Resource Types:
<ul>
{{- range (visibleTypes (sortedTypes .Types)) -}}
{{ if isExportedType . -}}
<li>
<a href="{{ linkForType . }}">{{ typeDisplayName . }}</a>
</li>
{{- end }}
{{- end -}}
</ul>

{{ range (visibleTypes (sortedTypes .Types))}}
{{ template "type" . }}
{{ end }}
Expand Down
34 changes: 30 additions & 4 deletions docs/api-doc-gen/templates/type.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{ define "type" }}

<h3 id="{{ anchorIDForType . }}">
{{- .Name.Name }}
{{ if eq .Kind "Alias" }}(<code>{{.Underlying}}</code> alias)</p>{{ end -}}
</h3>
{{ if isExportedType . -}}
## {{- .Name.Name }} { #{{ anchorIDForType . }} }
{{ else -}}
### {{- .Name.Name }} { #{{ anchorIDForType . }} }
{{ end -}}

{{ with (typeReferences .) }}
<p>
(<em>Appears on:</em>
Expand All @@ -22,6 +24,30 @@
{{ safe (renderComments .CommentLines) }}
</p>

{{ with (constantsOfType .) }}
<table>
<thead>
<tr>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{{- range . -}}
<tr>
{{- /*
renderComments implicitly creates a <p> element, so we
add one to the display name as well to make the contents
of the two cells align evenly.
*/ -}}
<td><p>{{ typeDisplayName . }}</p></td>
<td>{{ safe (renderComments .CommentLines) }}</td>
</tr>
{{- end -}}
</tbody>
</table>
{{ end }}

{{ if .Members }}
<table>
<thead>
Expand Down
Loading