Skip to content

Commit 53ac926

Browse files
DirectXMan12camilamacedo86
authored andcommitted
📖 re-enable golangci-lint's godoc comment checking
1 parent df180ac commit 53ac926

File tree

12 files changed

+108
-26
lines changed

12 files changed

+108
-26
lines changed

.golangci.yml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
linters:
2-
disable-all: true
3-
enable:
4-
- misspell
5-
- structcheck
6-
- golint
7-
- govet
8-
- deadcode
9-
- errcheck
10-
- varcheck
11-
- goconst
12-
- unparam
13-
- ineffassign
14-
- nakedret
15-
- interfacer
16-
- gocyclo
17-
- lll
18-
- dupl
19-
- goimports
20-
1+
run:
2+
deadline: 5m
213
linters-settings:
224
lll:
235
line-length: 170
246
dupl:
257
threshold: 400
8+
issues:
9+
# don't skip warning about doc comments
10+
exclude-use-default: false
2611

27-
run:
28-
timeout: 5m
12+
# restore some of the defaults
13+
# (fill in the rest as needed)
14+
exclude-rules:
15+
- linters: [errcheck]
16+
text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
17+
linters:
18+
disable-all: true
19+
enable:
20+
- misspell
21+
- structcheck
22+
- golint
23+
- govet
24+
- deadcode
25+
- errcheck
26+
- varcheck
27+
- goconst
28+
- unparam
29+
- ineffassign
30+
- nakedret
31+
- interfacer
32+
- gocyclo
33+
- lll
34+
- dupl
35+
- goimports
36+
- golint

pkg/builder/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,22 @@ func WithPredicates(predicates ...predicate.Predicate) Predicates {
5151
}
5252
}
5353

54+
// Predicates filters events before enqueuing the keys.
5455
type Predicates struct {
5556
predicates []predicate.Predicate
5657
}
5758

59+
// ApplyToFor applies this configuration to the given ForInput options.
5860
func (w Predicates) ApplyToFor(opts *ForInput) {
5961
opts.predicates = w.predicates
6062
}
63+
64+
// ApplyToOwns applies this configuration to the given OwnsInput options.
6165
func (w Predicates) ApplyToOwns(opts *OwnsInput) {
6266
opts.predicates = w.predicates
6367
}
68+
69+
// ApplyToWatches applies this configuration to the given WatchesInput options.
6470
func (w Predicates) ApplyToWatches(opts *WatchesInput) {
6571
opts.predicates = w.predicates
6672
}

pkg/builder/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type WebhookBuilder struct {
3838
config *rest.Config
3939
}
4040

41+
// WebhookManagedBy allows inform its manager.Manager
4142
func WebhookManagedBy(m manager.Manager) *WebhookBuilder {
4243
return &WebhookBuilder{mgr: m}
4344
}

pkg/client/fake/doc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ limitations under the License.
1515
*/
1616

1717
/*
18+
Package fake provides a fake client for testing.
19+
1820
Deprecated: please use pkg/envtest for testing. This package will be dropped
1921
before the v1.0.0 release.
20-
Package fake provides a fake client for testing.
2122
2223
An fake client is backed by its simple object store indexed by GroupVersionResource.
2324
You can create a fake client with optional objects.

pkg/client/options.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,40 @@ var DryRunAll = dryRunAll{}
7171

7272
type dryRunAll struct{}
7373

74+
// ApplyToCreate applies this configuration to the given create options.
7475
func (dryRunAll) ApplyToCreate(opts *CreateOptions) {
7576
opts.DryRun = []string{metav1.DryRunAll}
7677
}
78+
79+
// ApplyToUpdate applies this configuration to the given update options.
7780
func (dryRunAll) ApplyToUpdate(opts *UpdateOptions) {
7881
opts.DryRun = []string{metav1.DryRunAll}
7982
}
83+
84+
// ApplyToPatch applies this configuration to the given patch options.
8085
func (dryRunAll) ApplyToPatch(opts *PatchOptions) {
8186
opts.DryRun = []string{metav1.DryRunAll}
8287
}
88+
89+
// ApplyToPatch applies this configuration to the given delete options.
8390
func (dryRunAll) ApplyToDelete(opts *DeleteOptions) {
8491
opts.DryRun = []string{metav1.DryRunAll}
8592
}
8693

8794
// FieldOwner set the field manager name for the given server-side apply patch.
8895
type FieldOwner string
8996

97+
// ApplyToPatch applies this configuration to the given patch options.
9098
func (f FieldOwner) ApplyToPatch(opts *PatchOptions) {
9199
opts.FieldManager = string(f)
92100
}
101+
102+
// ApplyToCreate applies this configuration to the given create options.
93103
func (f FieldOwner) ApplyToCreate(opts *CreateOptions) {
94104
opts.FieldManager = string(f)
95105
}
106+
107+
// ApplyToUpdate applies this configuration to the given update options.
96108
func (f FieldOwner) ApplyToUpdate(opts *UpdateOptions) {
97109
opts.FieldManager = string(f)
98110
}
@@ -252,33 +264,49 @@ func (o *DeleteOptions) ApplyToDelete(do *DeleteOptions) {
252264
// to the given number of seconds.
253265
type GracePeriodSeconds int64
254266

267+
// ApplyToDelete applies this configuration to the given delete options.
255268
func (s GracePeriodSeconds) ApplyToDelete(opts *DeleteOptions) {
256269
secs := int64(s)
257270
opts.GracePeriodSeconds = &secs
258271
}
259272

273+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
260274
func (s GracePeriodSeconds) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
261275
s.ApplyToDelete(&opts.DeleteOptions)
262276
}
263277

278+
// Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.
264279
type Preconditions metav1.Preconditions
265280

281+
// ApplyToDelete applies this configuration to the given delete options.
266282
func (p Preconditions) ApplyToDelete(opts *DeleteOptions) {
267283
preconds := metav1.Preconditions(p)
268284
opts.Preconditions = &preconds
269285
}
270286

287+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
271288
func (p Preconditions) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
272289
p.ApplyToDelete(&opts.DeleteOptions)
273290
}
274291

292+
// PropagationPolicy determined whether and how garbage collection will be
293+
// performed. Either this field or OrphanDependents may be set, but not both.
294+
// The default policy is decided by the existing finalizer set in the
295+
// metadata.finalizers and the resource-specific default policy.
296+
// Acceptable values are: 'Orphan' - orphan the dependents; 'Background' -
297+
// allow the garbage collector to delete the dependents in the background;
298+
// 'Foreground' - a cascading policy that deletes all dependents in the
299+
// foreground.
275300
type PropagationPolicy metav1.DeletionPropagation
276301

302+
// ApplyToDelete applies the given delete options on these options.
303+
// It will propagate to the dependents of the object to let the garbage collector handle it.
277304
func (p PropagationPolicy) ApplyToDelete(opts *DeleteOptions) {
278305
policy := metav1.DeletionPropagation(p)
279306
opts.PropagationPolicy = &policy
280307
}
281308

309+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
282310
func (p PropagationPolicy) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
283311
p.ApplyToDelete(&opts.DeleteOptions)
284312
}
@@ -379,12 +407,14 @@ func (o *ListOptions) ApplyOptions(opts []ListOption) *ListOptions {
379407
// MatchingLabels filters the list/delete operation on the given set of labels.
380408
type MatchingLabels map[string]string
381409

410+
// ApplyToList applies this configuration to the given list options.
382411
func (m MatchingLabels) ApplyToList(opts *ListOptions) {
383412
// TODO(directxman12): can we avoid reserializing this over and over?
384413
sel := labels.SelectorFromValidatedSet(map[string]string(m))
385414
opts.LabelSelector = sel
386415
}
387416

417+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
388418
func (m MatchingLabels) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
389419
m.ApplyToList(&opts.ListOptions)
390420
}
@@ -393,6 +423,7 @@ func (m MatchingLabels) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
393423
// without checking their values.
394424
type HasLabels []string
395425

426+
// ApplyToList applies this configuration to the given list options.
396427
func (m HasLabels) ApplyToList(opts *ListOptions) {
397428
sel := labels.NewSelector()
398429
for _, label := range m {
@@ -404,6 +435,7 @@ func (m HasLabels) ApplyToList(opts *ListOptions) {
404435
opts.LabelSelector = sel
405436
}
406437

438+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
407439
func (m HasLabels) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
408440
m.ApplyToList(&opts.ListOptions)
409441
}
@@ -415,10 +447,12 @@ type MatchingLabelsSelector struct {
415447
labels.Selector
416448
}
417449

450+
// ApplyToList applies this configuration to the given list options.
418451
func (m MatchingLabelsSelector) ApplyToList(opts *ListOptions) {
419452
opts.LabelSelector = m
420453
}
421454

455+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
422456
func (m MatchingLabelsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
423457
m.ApplyToList(&opts.ListOptions)
424458
}
@@ -435,12 +469,14 @@ func MatchingField(name, val string) MatchingFields {
435469
// (or index in the case of cached lists).
436470
type MatchingFields fields.Set
437471

472+
// ApplyToList applies this configuration to the given list options.
438473
func (m MatchingFields) ApplyToList(opts *ListOptions) {
439474
// TODO(directxman12): can we avoid re-serializing this?
440475
sel := fields.Set(m).AsSelector()
441476
opts.FieldSelector = sel
442477
}
443478

479+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
444480
func (m MatchingFields) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
445481
m.ApplyToList(&opts.ListOptions)
446482
}
@@ -452,21 +488,25 @@ type MatchingFieldsSelector struct {
452488
fields.Selector
453489
}
454490

491+
// ApplyToList applies this configuration to the given list options.
455492
func (m MatchingFieldsSelector) ApplyToList(opts *ListOptions) {
456493
opts.FieldSelector = m
457494
}
458495

496+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
459497
func (m MatchingFieldsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
460498
m.ApplyToList(&opts.ListOptions)
461499
}
462500

463501
// InNamespace restricts the list/delete operation to the given namespace.
464502
type InNamespace string
465503

504+
// ApplyToList applies this configuration to the given list options.
466505
func (n InNamespace) ApplyToList(opts *ListOptions) {
467506
opts.Namespace = string(n)
468507
}
469508

509+
// ApplyToDeleteAllOf applies this configuration to the given an List options.
470510
func (n InNamespace) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
471511
n.ApplyToList(&opts.ListOptions)
472512
}
@@ -476,6 +516,7 @@ func (n InNamespace) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
476516
// does not support setting it for deletecollection operations.
477517
type Limit int64
478518

519+
// ApplyToList applies this configuration to the given an list options.
479520
func (l Limit) ApplyToList(opts *ListOptions) {
480521
opts.Limit = int64(l)
481522
}
@@ -485,6 +526,7 @@ func (l Limit) ApplyToList(opts *ListOptions) {
485526
// does not support setting it for deletecollection operations.
486527
type Continue string
487528

529+
// ApplyToList applies this configuration to the given an List options.
488530
func (c Continue) ApplyToList(opts *ListOptions) {
489531
opts.Continue = string(c)
490532
}

pkg/controller/controllertest/unconventionallisttypecrd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func (u *UnconventionalListType) DeepCopyObject() runtime.Object {
2222
return u.DeepCopy()
2323
}
2424

25+
// DeepCopy implements *UnconventionalListType
26+
// Handwritten for simplicity.
2527
func (u *UnconventionalListType) DeepCopy() *UnconventionalListType {
2628
return &UnconventionalListType{
2729
TypeMeta: u.TypeMeta,
@@ -44,6 +46,8 @@ func (u *UnconventionalListTypeList) DeepCopyObject() runtime.Object {
4446
return u.DeepCopy()
4547
}
4648

49+
// DeepCopy implements *UnconventionalListTypeListt
50+
// Handwritten for simplicity.
4751
func (u *UnconventionalListTypeList) DeepCopy() *UnconventionalListTypeList {
4852
out := &UnconventionalListTypeList{
4953
TypeMeta: u.TypeMeta,

pkg/internal/testing/integration/internal/apiserver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package internal
22

3+
// APIServerDefaultArgs allow tests to run offline, by preventing API server from attempting to
4+
// use default route to determine its --advertise-address.
35
var APIServerDefaultArgs = []string{
4-
// Allow tests to run offline, by preventing API server from attempting to
5-
// use default route to determine its --advertise-address
66
"--advertise-address=127.0.0.1",
77
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
88
"--cert-dir={{ .CertDir }}",
@@ -14,6 +14,8 @@ var APIServerDefaultArgs = []string{
1414
"--allow-privileged=true",
1515
}
1616

17+
// DoAPIServerArgDefaulting will set default values to allow tests to run offline when the args are not informed. Otherwise,
18+
// it will return the same []string arg passed as param.
1719
func DoAPIServerArgDefaulting(args []string) []string {
1820
if len(args) != 0 {
1921
return args

pkg/internal/testing/integration/internal/arguments.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"html/template"
66
)
77

8+
// RenderTemplates returns an []string to render the templates
89
func RenderTemplates(argTemplates []string, data interface{}) (args []string, err error) {
910
var t *template.Template
1011

pkg/internal/testing/integration/internal/etcd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import (
44
"net/url"
55
)
66

7+
// EtcdDefaultArgs allow tests to run offline, by preventing API server from attempting to
8+
// use default route to determine its urls.
79
var EtcdDefaultArgs = []string{
810
"--listen-peer-urls=http://localhost:0",
911
"--advertise-client-urls={{ if .URL }}{{ .URL.String }}{{ end }}",
1012
"--listen-client-urls={{ if .URL }}{{ .URL.String }}{{ end }}",
1113
"--data-dir={{ .DataDir }}",
1214
}
1315

16+
// DoEtcdArgDefaulting will set default values to allow tests to run offline when the args are not informed. Otherwise,
17+
// it will return the same []string arg passed as param.
1418
func DoEtcdArgDefaulting(args []string) []string {
1519
if len(args) != 0 {
1620
return args
@@ -19,6 +23,7 @@ func DoEtcdArgDefaulting(args []string) []string {
1923
return EtcdDefaultArgs
2024
}
2125

26+
// isSecureScheme returns false when the schema is insecure.
2227
func isSecureScheme(scheme string) bool {
2328
// https://github.com/coreos/etcd/blob/d9deeff49a080a88c982d328ad9d33f26d1ad7b6/pkg/transport/listener.go#L53
2429
if scheme == "https" || scheme == "unixs" {
@@ -27,6 +32,8 @@ func isSecureScheme(scheme string) bool {
2732
return false
2833
}
2934

35+
// GetEtcdStartMessage returns an start message to inform if the client is or not insecure.
36+
// It will return true when the URL informed has the scheme == "https" || scheme == "unixs"
3037
func GetEtcdStartMessage(listenURL url.URL) string {
3138
if isSecureScheme(listenURL.Scheme) {
3239
// https://github.com/coreos/etcd/blob/a7f1fbe00ec216fcb3a1919397a103b41dca8413/embed/serve.go#L167

pkg/internal/testing/integration/internal/integration_tests/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Package integrariontests is holding the integration tests to run against the
2+
Package integrationtests holds the integration tests to run against the
33
framework.
44
55
This file's only purpose is to make godep happy.

0 commit comments

Comments
 (0)