Skip to content

Commit 19bf0c7

Browse files
🐛 (CLI, deploy-image/v1alpha1, go/v4) Ensure consistent spacing in marker annotations (#3904)
This commit addresses the inconsistency in marker annotations within the kubebuilder project. Previously, kubebuilder markers did not have a space between `//` and `+marker`, unlike those in controller-tools and other related tools see; - controller-tools: https://github.com/search?q=repo%3Akubernetes-sigs%2Fcontroller-tools+%22%2F%2F+%2B%22&type=code. - controller-runtime: https://github.com/search?q=repo%3Akubernetes-sigs%2Fcontroller-runtime++%22%2F%2F+%2B%22&type=code **This inconsistency was causing confusion for end users.** To resolve this, all kubebuilder markers are now updated to include a space, ensuring uniformity across the project. After merging this commit, you can run `make all` to regenerate the markers. If any issues arise, use find/replace to change `//+` to `// +`.
1 parent 7ac9305 commit 19bf0c7

File tree

154 files changed

+496
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+496
-491
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Provide clean library abstractions with clear and well exampled godocs.
9797
- Start minimal and provide progressive discovery of functionality
9898
- Provide sane defaults and allow users to override when they exist
9999
- Provide code generators to maintain common boilerplate that can't be addressed by interfaces
100-
- Driven off of `//+` comments
100+
- Driven off of `// +` comments
101101
- Provide bootstrapping commands to initialize new packages
102102

103103
## Versioning and Releasing

docs/book/src/cronjob-tutorial/testdata/emptyapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ a Kind. Then, the `object` generator generates an implementation of the
6969
interface that all types representing Kinds must implement.
7070
*/
7171

72-
//+kubebuilder:object:root=true
73-
//+kubebuilder:subresource:status
72+
// +kubebuilder:object:root=true
73+
// +kubebuilder:subresource:status
7474

7575
// CronJob is the Schema for the cronjobs API
7676
type CronJob struct {
@@ -81,7 +81,7 @@ type CronJob struct {
8181
Status CronJobStatus `json:"status,omitempty"`
8282
}
8383

84-
//+kubebuilder:object:root=true
84+
// +kubebuilder:object:root=true
8585

8686
// CronJobList contains a list of CronJob
8787
type CronJobList struct {

docs/book/src/cronjob-tutorial/testdata/emptymain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var (
6262
func init() {
6363
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
6464

65-
//+kubebuilder:scaffold:scheme
65+
// +kubebuilder:scaffold:scheme
6666
}
6767

6868
/*

docs/book/src/cronjob-tutorial/testdata/finalizer_example.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import (
3838
By default, kubebuilder will include the RBAC rules necessary to update finalizers for CronJobs.
3939
*/
4040

41-
//+kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
42-
//+kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs/status,verbs=get;update;patch
43-
//+kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs/finalizers,verbs=update
41+
// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
42+
// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs/status,verbs=get;update;patch
43+
// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs/finalizers,verbs=update
4444

4545
/*
4646
The code snippet below shows skeleton code for implementing a finalizer.

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ import (
6464

6565
// CronJobSpec defines the desired state of CronJob
6666
type CronJobSpec struct {
67-
//+kubebuilder:validation:MinLength=0
67+
// +kubebuilder:validation:MinLength=0
6868

6969
// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
7070
Schedule string `json:"schedule"`
7171

72-
//+kubebuilder:validation:Minimum=0
72+
// +kubebuilder:validation:Minimum=0
7373

7474
// Optional deadline in seconds for starting the job if it misses scheduled
7575
// time for any reason. Missed jobs executions will be counted as failed ones.
@@ -92,14 +92,14 @@ type CronJobSpec struct {
9292
// Specifies the job that will be created when executing a CronJob.
9393
JobTemplate batchv1.JobTemplateSpec `json:"jobTemplate"`
9494

95-
//+kubebuilder:validation:Minimum=0
95+
// +kubebuilder:validation:Minimum=0
9696

9797
// The number of successful finished jobs to retain.
9898
// This is a pointer to distinguish between explicit zero and not specified.
9999
// +optional
100100
SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"`
101101

102-
//+kubebuilder:validation:Minimum=0
102+
// +kubebuilder:validation:Minimum=0
103103

104104
// The number of failed finished jobs to retain.
105105
// This is a pointer to distinguish between explicit zero and not specified.
@@ -162,8 +162,8 @@ type CronJobStatus struct {
162162
we want a status subresource, so that we behave like built-in kubernetes types.
163163
*/
164164

165-
//+kubebuilder:object:root=true
166-
//+kubebuilder:subresource:status
165+
// +kubebuilder:object:root=true
166+
// +kubebuilder:subresource:status
167167

168168
// CronJob is the Schema for the cronjobs API
169169
type CronJob struct {
@@ -176,7 +176,7 @@ type CronJob struct {
176176
Status CronJobStatus `json:"status,omitempty"`
177177
}
178178

179-
//+kubebuilder:object:root=true
179+
// +kubebuilder:object:root=true
180180

181181
// CronJobList contains a list of CronJob
182182
type CronJobList struct {
@@ -189,4 +189,4 @@ func init() {
189189
SchemeBuilder.Register(&CronJob{}, &CronJobList{})
190190
}
191191

192-
//+kubebuilder:docs-gen:collapse=Root Object Definitions
192+
// +kubebuilder:docs-gen:collapse=Root Object Definitions

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This marker is responsible for generating a mutating webhook manifest.
5656
The meaning of each marker can be found [here](/reference/markers/webhook.md).
5757
*/
5858

59-
//+kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,sideEffects=None,admissionReviewVersions=v1
59+
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,sideEffects=None,admissionReviewVersions=v1
6060

6161
/*
6262
We use the `webhook.Defaulter` interface to set defaults to our CRD.
@@ -91,7 +91,7 @@ func (r *CronJob) Default() {
9191
This marker is responsible for generating a validating webhook manifest.
9292
*/
9393

94-
//+kubebuilder:webhook:verbs=create;update;delete,path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,versions=v1,name=vcronjob.kb.io,sideEffects=None,admissionReviewVersions=v1
94+
// +kubebuilder:webhook:verbs=create;update;delete,path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,versions=v1,name=vcronjob.kb.io,sideEffects=None,admissionReviewVersions=v1
9595

9696
/*
9797
We can validate our CRD beyond what's possible with declarative

docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
. "github.com/onsi/gomega"
3131

3232
admissionv1 "k8s.io/api/admission/v1"
33-
//+kubebuilder:scaffold:imports
33+
// +kubebuilder:scaffold:imports
3434
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
3535
"k8s.io/client-go/rest"
3636
ctrl "sigs.k8s.io/controller-runtime"
@@ -93,7 +93,7 @@ var _ = BeforeSuite(func() {
9393
err = admissionv1.AddToScheme(scheme)
9494
Expect(err).NotTo(HaveOccurred())
9595

96-
//+kubebuilder:scaffold:scheme
96+
// +kubebuilder:scaffold:scheme
9797

9898
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
9999
Expect(err).NotTo(HaveOccurred())
@@ -116,7 +116,7 @@ var _ = BeforeSuite(func() {
116116
err = (&CronJob{}).SetupWebhookWithManager(mgr)
117117
Expect(err).NotTo(HaveOccurred())
118118

119-
//+kubebuilder:scaffold:webhook
119+
// +kubebuilder:scaffold:webhook
120120

121121
go func() {
122122
defer GinkgoRecover()

docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737

3838
batchv1 "tutorial.kubebuilder.io/project/api/v1"
3939
"tutorial.kubebuilder.io/project/internal/controller"
40-
//+kubebuilder:scaffold:imports
40+
// +kubebuilder:scaffold:imports
4141
)
4242

4343
// +kubebuilder:docs-gen:collapse=Imports
@@ -60,7 +60,7 @@ func init() {
6060
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
6161

6262
utilruntime.Must(batchv1.AddToScheme(scheme))
63-
//+kubebuilder:scaffold:scheme
63+
// +kubebuilder:scaffold:scheme
6464
}
6565

6666
/*
@@ -166,7 +166,7 @@ func main() {
166166
os.Exit(1)
167167
}
168168
}
169-
//+kubebuilder:scaffold:builder
169+
// +kubebuilder:scaffold:builder
170170

171171
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
172172
setupLog.Error(err, "unable to set up health check")

docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
# It should be run by config/default
44
resources:
55
- bases/batch.tutorial.kubebuilder.io_cronjobs.yaml
6-
#+kubebuilder:scaffold:crdkustomizeresource
6+
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patches:
99
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
1111
- path: patches/webhook_in_cronjobs.yaml
12-
#+kubebuilder:scaffold:crdkustomizewebhookpatch
12+
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1313

1414
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1515
# patches here are for enabling the CA injection for each CRD
1616
- path: patches/cainjection_in_cronjobs.yaml
17-
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
17+
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
1818

1919
# [WEBHOOK] To enable webhook, uncomment the following section
2020
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Append samples of your project ##
22
resources:
33
- batch_v1_cronjob.yaml
4-
#+kubebuilder:scaffold:manifestskustomizesamples
4+
# +kubebuilder:scaffold:manifestskustomizesamples

0 commit comments

Comments
 (0)