Skip to content

Commit c4242a0

Browse files
committed
✨ (scaffolding/templates): Improve format for stricter linter (#4132)
1 parent 33a2f3d commit c4242a0

File tree

107 files changed

+498
-474
lines changed

Some content is hidden

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

107 files changed

+498
-474
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import (
6262
the fields.
6363
*/
6464

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

@@ -142,7 +142,7 @@ const (
142142
serialization, as mentioned above.
143143
*/
144144

145-
// CronJobStatus defines the observed state of CronJob
145+
// CronJobStatus defines the observed state of CronJob.
146146
type CronJobStatus struct {
147147
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
148148
// Important: Run "make" to regenerate code after modifying this file
@@ -165,7 +165,7 @@ type CronJobStatus struct {
165165
// +kubebuilder:object:root=true
166166
// +kubebuilder:subresource:status
167167

168-
// CronJob is the Schema for the cronjobs API
168+
// CronJob is the Schema for the cronjobs API.
169169
type CronJob struct {
170170
/*
171171
*/
@@ -178,7 +178,7 @@ type CronJob struct {
178178

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

181-
// CronJobList contains a list of CronJob
181+
// CronJobList contains a list of CronJob.
182182
type CronJobList struct {
183183
metav1.TypeMeta `json:",inline"`
184184
metav1.ListMeta `json:"metadata,omitempty"`

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var cronjoblog = logf.Log.WithName("cronjob-resource")
4545
Then, we set up the webhook with the manager.
4646
*/
4747

48-
// SetupWebhookWithManager will setup the manager to manage the webhooks
48+
// SetupWebhookWithManager will setup the manager to manage the webhooks.
4949
func (r *CronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
5050
return ctrl.NewWebhookManagedBy(mgr).
5151
For(r).
@@ -92,7 +92,7 @@ type CronJobCustomDefaulter struct {
9292

9393
var _ webhook.CustomDefaulter = &CronJobCustomDefaulter{}
9494

95-
// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind CronJob
95+
// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind CronJob.
9696
func (d *CronJobCustomDefaulter) Default(ctx context.Context, obj runtime.Object) error {
9797
cronjob, ok := obj.(*CronJob)
9898
if !ok {
@@ -161,7 +161,7 @@ type CronJobCustomValidator struct {
161161

162162
var _ webhook.CustomValidator = &CronJobCustomValidator{}
163163

164-
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type CronJob
164+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type CronJob.
165165
func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
166166
cronjob, ok := obj.(*CronJob)
167167
if !ok {
@@ -172,7 +172,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
172172
return nil, cronjob.validateCronJob()
173173
}
174174

175-
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type CronJob
175+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type CronJob.
176176
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
177177
cronjob, ok := newObj.(*CronJob)
178178
if !ok {
@@ -183,7 +183,7 @@ func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, new
183183
return nil, cronjob.validateCronJob()
184184
}
185185

186-
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type CronJob
186+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type CronJob.
187187
func (v *CronJobCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
188188
cronjob, ok := obj.(*CronJob)
189189
if !ok {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ former, while the latter is used by the CRD generator to generate the right
2323
metadata for the CRDs it creates from this package.
2424
*/
2525

26-
// Package v1 contains API Schema definitions for the batch v1 API group
26+
// Package v1 contains API Schema definitions for the batch v1 API group.
2727
// +kubebuilder:object:generate=true
2828
// +groupName=batch.tutorial.kubebuilder.io
2929
package v1
@@ -41,10 +41,10 @@ some other `Scheme`. SchemeBuilder makes this easy for us.
4141
*/
4242

4343
var (
44-
// GroupVersion is group version used to register these objects
44+
// GroupVersion is group version used to register these objects.
4545
GroupVersion = schema.GroupVersion{Group: "batch.tutorial.kubebuilder.io", Version: "v1"}
4646

47-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
47+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
4848
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
4949

5050
// AddToScheme adds the types in this group-version to the given scheme.

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ import (
4545
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
4646
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
4747

48-
var cfg *rest.Config
49-
var k8sClient client.Client
50-
var testEnv *envtest.Environment
51-
var ctx context.Context
52-
var cancel context.CancelFunc
48+
var (
49+
cancel context.CancelFunc
50+
cfg *rest.Config
51+
ctx context.Context
52+
k8sClient client.Client
53+
testEnv *envtest.Environment
54+
)
5355

5456
func TestAPIs(t *testing.T) {
5557
RegisterFailHandler(Fail)
@@ -99,7 +101,7 @@ var _ = BeforeSuite(func() {
99101
Expect(err).NotTo(HaveOccurred())
100102
Expect(k8sClient).NotTo(BeNil())
101103

102-
// start webhook server using Manager
104+
// start webhook server using Manager.
103105
webhookInstallOptions := &testEnv.WebhookInstallOptions
104106
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
105107
Scheme: scheme,
@@ -124,17 +126,17 @@ var _ = BeforeSuite(func() {
124126
Expect(err).NotTo(HaveOccurred())
125127
}()
126128

127-
// wait for the webhook server to get ready
129+
// wait for the webhook server to get ready.
128130
dialer := &net.Dialer{Timeout: time.Second}
129131
addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
130132
Eventually(func() error {
131133
conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
132134
if err != nil {
133135
return err
134136
}
137+
135138
return conn.Close()
136139
}).Should(Succeed())
137-
138140
})
139141

140142
var _ = AfterSuite(func() {

docs/book/src/getting-started/testdata/project/api/v1alpha1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the cache v1alpha1 API group
17+
// Package v1alpha1 contains API Schema definitions for the cache v1alpha1 API group.
1818
// +kubebuilder:object:generate=true
1919
// +groupName=cache.example.com
2020
package v1alpha1
@@ -25,10 +25,10 @@ import (
2525
)
2626

2727
var (
28-
// GroupVersion is group version used to register these objects
28+
// GroupVersion is group version used to register these objects.
2929
GroupVersion = schema.GroupVersion{Group: "cache.example.com", Version: "v1alpha1"}
3030

31-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3333

3434
// AddToScheme adds the types in this group-version to the given scheme.

docs/book/src/getting-started/testdata/project/api/v1alpha1/memcached_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
// +kubebuilder:docs-gen:collapse=Imports
2828

29-
// MemcachedSpec defines the desired state of Memcached
29+
// MemcachedSpec defines the desired state of Memcached.
3030
type MemcachedSpec struct {
3131
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3232
// Important: Run "make" to regenerate code after modifying this file
@@ -40,7 +40,7 @@ type MemcachedSpec struct {
4040
Size int32 `json:"size,omitempty"`
4141
}
4242

43-
// MemcachedStatus defines the observed state of Memcached
43+
// MemcachedStatus defines the observed state of Memcached.
4444
type MemcachedStatus struct {
4545
// Represents the observations of a Memcached's current state.
4646
// Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded"
@@ -57,7 +57,7 @@ type MemcachedStatus struct {
5757
// +kubebuilder:object:root=true
5858
// +kubebuilder:subresource:status
5959

60-
// Memcached is the Schema for the memcacheds API
60+
// Memcached is the Schema for the memcacheds API.
6161
type Memcached struct {
6262
metav1.TypeMeta `json:",inline"`
6363
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -68,7 +68,7 @@ type Memcached struct {
6868

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

71-
// MemcachedList contains a list of Memcached
71+
// MemcachedList contains a list of Memcached.
7272
type MemcachedList struct {
7373
metav1.TypeMeta `json:",inline"`
7474
metav1.ListMeta `json:"metadata,omitempty"`

docs/book/src/getting-started/testdata/project/config/crd/bases/cache.example.com_memcacheds.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: Memcached is the Schema for the memcacheds API
20+
description: Memcached is the Schema for the memcacheds API.
2121
properties:
2222
apiVersion:
2323
description: |-
@@ -37,7 +37,7 @@ spec:
3737
metadata:
3838
type: object
3939
spec:
40-
description: MemcachedSpec defines the desired state of Memcached
40+
description: MemcachedSpec defines the desired state of Memcached.
4141
properties:
4242
size:
4343
description: |-
@@ -50,7 +50,7 @@ spec:
5050
type: integer
5151
type: object
5252
status:
53-
description: MemcachedStatus defines the observed state of Memcached
53+
description: MemcachedStatus defines the observed state of Memcached.
5454
properties:
5555
conditions:
5656
items:

hack/docs/internal/cronjob-tutorial/generate_cronjob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ func (sp *Sample) updateSpec() {
194194

195195
err = pluginutil.ReplaceInFile(
196196
filepath.Join(sp.ctx.Dir, "api/v1/cronjob_types.go"),
197-
`// CronJob is the Schema for the cronjobs API
198-
type CronJob struct {`, `// CronJob is the Schema for the cronjobs API
197+
`// CronJob is the Schema for the cronjobs API.
198+
type CronJob struct {`, `// CronJob is the Schema for the cronjobs API.
199199
type CronJob struct {`+`
200200
/*
201201
*/`)

pkg/plugins/golang/v4/scaffolds/internal/templates/api/group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (f *Group) SetTemplateDefaults() error {
5454
//nolint:lll
5555
const groupTemplate = `{{ .Boilerplate }}
5656
57-
// Package {{ .Resource.Version }} contains API Schema definitions for the {{ .Resource.Group }} {{ .Resource.Version }} API group
57+
// Package {{ .Resource.Version }} contains API Schema definitions for the {{ .Resource.Group }} {{ .Resource.Version }} API group.
5858
// +kubebuilder:object:generate=true
5959
// +groupName={{ .Resource.QualifiedGroup }}
6060
package {{ .Resource.Version }}
@@ -65,10 +65,10 @@ import (
6565
)
6666
6767
var (
68-
// GroupVersion is group version used to register these objects
68+
// GroupVersion is group version used to register these objects.
6969
GroupVersion = schema.GroupVersion{Group: "{{ .Resource.QualifiedGroup }}", Version: "{{ .Resource.Version }}"}
7070
71-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
71+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
7272
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
7373
7474
// AddToScheme adds the types in this group-version to the given scheme.

pkg/plugins/golang/v4/scaffolds/internal/templates/api/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import (
7272
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
7373
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
7474
75-
// {{ .Resource.Kind }}Spec defines the desired state of {{ .Resource.Kind }}
75+
// {{ .Resource.Kind }}Spec defines the desired state of {{ .Resource.Kind }}.
7676
type {{ .Resource.Kind }}Spec struct {
7777
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
7878
// Important: Run "make" to regenerate code after modifying this file
@@ -81,7 +81,7 @@ type {{ .Resource.Kind }}Spec struct {
8181
Foo string ` + "`" + `json:"foo,omitempty"` + "`" + `
8282
}
8383
84-
// {{ .Resource.Kind }}Status defines the observed state of {{ .Resource.Kind }}
84+
// {{ .Resource.Kind }}Status defines the observed state of {{ .Resource.Kind }}.
8585
type {{ .Resource.Kind }}Status struct {
8686
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
8787
// Important: Run "make" to regenerate code after modifying this file
@@ -97,7 +97,7 @@ type {{ .Resource.Kind }}Status struct {
9797
// +kubebuilder:resource:path={{ .Resource.Plural }}
9898
{{- end }}
9999
100-
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
100+
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API.
101101
type {{ .Resource.Kind }} struct {
102102
metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
103103
metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
@@ -108,7 +108,7 @@ type {{ .Resource.Kind }} struct {
108108
109109
// +kubebuilder:object:root=true
110110
111-
// {{ .Resource.Kind }}List contains a list of {{ .Resource.Kind }}
111+
// {{ .Resource.Kind }}List contains a list of {{ .Resource.Kind }}.
112112
type {{ .Resource.Kind }}List struct {
113113
metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
114114
metav1.ListMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `

0 commit comments

Comments
 (0)