Skip to content

Commit

Permalink
fix: Add Markers and Move Comments for API Docs
Browse files Browse the repository at this point in the history
Update our code comment markers and copyright notice placement so that
the elastic/crd-ref-docs tool can generate API reference docs:

- Add `kubebuilder:object:root=true` marker for root CRD types. The
  crd-ref-docs tool looks for these to identify new `Kind` APIs.
- Move copyright comments so they are not mistaken for package-level
  docs.

Note - this only applies to the `v1beta1` API.

Signed-off-by: Adam Kaplan <[email protected]>
  • Loading branch information
adambkaplan committed Feb 17, 2025
1 parent 6ddd5ec commit c119ec1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pkg/apis/build/v1beta1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ type BuildStatus struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Build is the Schema representing a Build definition
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=builds,scope=Namespaced
Expand All @@ -327,6 +326,8 @@ type BuildStatus struct {
// +kubebuilder:printcolumn:name="BuildStrategyKind",type="string",JSONPath=".spec.strategy.kind",description="The BuildStrategy type which is used for this Build"
// +kubebuilder:printcolumn:name="BuildStrategyName",type="string",JSONPath=".spec.strategy.name",description="The BuildStrategy name which is used for this Build"
// +kubebuilder:printcolumn:name="CreationTime",type="date",JSONPath=".metadata.creationTimestamp",description="The create time of this Build"

// Build is the Schema representing a Build definition
type Build struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -336,6 +337,7 @@ type Build struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// BuildList contains a list of Build
type BuildList struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/build/v1beta1/buildrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,16 @@ type FailureDetails struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BuildRun is the Schema representing an instance of build execution
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=buildruns,scope=Namespaced,shortName=br;brs
// +kubebuilder:printcolumn:name="Succeeded",type="string",JSONPath=".status.conditions[?(@.type==\"Succeeded\")].status",description="The Succeeded status of the BuildRun"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type==\"Succeeded\")].reason",description="The Succeeded reason of the BuildRun"
// +kubebuilder:printcolumn:name="StartTime",type="date",JSONPath=".status.startTime",description="The start time of this BuildRun"
// +kubebuilder:printcolumn:name="CompletionTime",type="date",JSONPath=".status.completionTime",description="The completion time of this BuildRun"

// BuildRun is the Schema representing an instance of build execution
type BuildRun struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -286,6 +287,7 @@ type BuildRun struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// BuildRunList contains a list of BuildRun
type BuildRunList struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/build/v1beta1/buildstrategy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ const (

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BuildStrategy is the Schema representing a strategy in the namespace scope to build images from source code.
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=buildstrategies,scope=Namespaced,shortName=bs;bss

// BuildStrategy is the Schema representing a strategy in the namespace scope to build images from source code.
type BuildStrategy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -37,6 +38,7 @@ type BuildStrategy struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// BuildStrategyList contains a list of BuildStrategy
type BuildStrategyList struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/build/v1beta1/clusterbuildstrategy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ const (
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterBuildStrategy is the Schema representing a strategy in the cluster scope to build images from source code.
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=clusterbuildstrategies,scope=Cluster,shortName=cbs;cbss

// ClusterBuildStrategy is the Schema representing a strategy in the cluster scope to build images from source code.
type ClusterBuildStrategy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -38,6 +39,7 @@ type ClusterBuildStrategy struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// ClusterBuildStrategyList contains a list of ClusterBuildStrategy
type ClusterBuildStrategyList struct {
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/build/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

// NOTE: Boilerplate only. Ignore this file.

// Package v1beta1 contains API Schema definitions for the build v1beta1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=shipwright.io
package v1beta1

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/build/v1beta1/trigger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright The Shipwright Contributors
//
// SPDX-License-Identifier: Apache-2.0

package v1beta1

// Trigger represents the webhook trigger configuration for a Build.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/build/v1beta1/trigger_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright The Shipwright Contributors
//
// SPDX-License-Identifier: Apache-2.0

package v1beta1

// TriggerType set of TriggerWhen valid names.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/build/v1beta1/trigger_when.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright The Shipwright Contributors
//
// SPDX-License-Identifier: Apache-2.0

package v1beta1

// TriggerWhen a given scenario where the webhook trigger is applicable.
Expand Down

0 comments on commit c119ec1

Please sign in to comment.