Skip to content

Commit 4b208ab

Browse files
committed
Bump golangci lint to v1.49.0
1 parent 02dc464 commit 4b208ab

File tree

27 files changed

+187
-173
lines changed

27 files changed

+187
-173
lines changed

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
- name: golangci-lint
2020
uses: golangci/golangci-lint-action@v2
2121
with:
22-
version: v1.47.3
22+
version: v1.49.0
2323
working-directory: ${{matrix.working-directory}}

.golangci.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ linters:
1212
- goconst
1313
- gocritic
1414
- gocyclo
15-
- godot
1615
- gofmt
1716
- goimports
1817
- goprintffuncname
@@ -61,9 +60,9 @@ linters-settings:
6160
- pkg: sigs.k8s.io/controller-runtime
6261
alias: ctrl
6362
staticcheck:
64-
go: "1.18"
63+
go: "1.19"
6564
stylecheck:
66-
go: "1.18"
65+
go: "1.19"
6766
depguard:
6867
include-go-root: true
6968
packages:
@@ -132,6 +131,9 @@ issues:
132131
- linters:
133132
- gosec
134133
text: "G304: Potential file inclusion via variable"
134+
- linters:
135+
- revive
136+
text: "package-comments: should have a package comment"
135137

136138
run:
137139
timeout: 10m

doc.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ limitations under the License.
2323
// and uncommon cases should be possible. In general, controller-runtime tries
2424
// to guide users towards Kubernetes controller best-practices.
2525
//
26-
// Getting Started
26+
// # Getting Started
2727
//
2828
// The main entrypoint for controller-runtime is this root package, which
2929
// contains all of the common types needed to get started building controllers:
30-
// import (
31-
// ctrl "sigs.k8s.io/controller-runtime"
32-
// )
30+
//
31+
// import (
32+
// ctrl "sigs.k8s.io/controller-runtime"
33+
// )
3334
//
3435
// The examples in this package walk through a basic controller setup. The
3536
// kubebuilder book (https://book.kubebuilder.io) has some more in-depth
@@ -38,7 +39,7 @@ limitations under the License.
3839
// controller-runtime favors structs with sane defaults over constructors, so
3940
// it's fairly common to see structs being used directly in controller-runtime.
4041
//
41-
// Organization
42+
// # Organization
4243
//
4344
// A brief-ish walkthrough of the layout of this library can be found below. Each
4445
// package contains more information about how to use it.
@@ -47,7 +48,7 @@ limitations under the License.
4748
// controllers can be found at
4849
// https://github.com/kubernetes-sigs/controller-runtime/blob/master/FAQ.md.
4950
//
50-
// Managers
51+
// # Managers
5152
//
5253
// Every controller and webhook is ultimately run by a Manager (pkg/manager). A
5354
// manager is responsible for running controllers and webhooks, and setting up
@@ -56,7 +57,7 @@ limitations under the License.
5657
// generally configured to gracefully shut down controllers on pod termination
5758
// by wiring up a signal handler (pkg/manager/signals).
5859
//
59-
// Controllers
60+
// # Controllers
6061
//
6162
// Controllers (pkg/controller) use events (pkg/event) to eventually trigger
6263
// reconcile requests. They may be constructed manually, but are often
@@ -67,15 +68,15 @@ limitations under the License.
6768
// trigger reconciles. There are pre-written utilities for the common cases, and
6869
// interfaces and helpers for advanced cases.
6970
//
70-
// Reconcilers
71+
// # Reconcilers
7172
//
7273
// Controller logic is implemented in terms of Reconcilers (pkg/reconcile). A
7374
// Reconciler implements a function which takes a reconcile Request containing
7475
// the name and namespace of the object to reconcile, reconciles the object,
7576
// and returns a Response or an error indicating whether to requeue for a
7677
// second round of processing.
7778
//
78-
// Clients and Caches
79+
// # Clients and Caches
7980
//
8081
// Reconcilers use Clients (pkg/client) to access API objects. The default
8182
// client provided by the manager reads from a local shared cache (pkg/cache)
@@ -91,19 +92,19 @@ limitations under the License.
9192
// may retrieve event recorders (pkg/recorder) to emit events using the
9293
// manager.
9394
//
94-
// Schemes
95+
// # Schemes
9596
//
9697
// Clients, Caches, and many other things in Kubernetes use Schemes
9798
// (pkg/scheme) to associate Go types to Kubernetes API Kinds
9899
// (Group-Version-Kinds, to be specific).
99100
//
100-
// Webhooks
101+
// # Webhooks
101102
//
102103
// Similarly, webhooks (pkg/webhook/admission) may be implemented directly, but
103104
// are often constructed using a builder (pkg/webhook/admission/builder). They
104105
// are run via a server (pkg/webhook) which is managed by a Manager.
105106
//
106-
// Logging and Metrics
107+
// # Logging and Metrics
107108
//
108109
// Logging (pkg/log) in controller-runtime is done via structured logs, using a
109110
// log set of interfaces called logr
@@ -117,7 +118,7 @@ limitations under the License.
117118
// serve these by an HTTP endpoint, and additional metrics may be registered to
118119
// this Registry as normal.
119120
//
120-
// Testing
121+
// # Testing
121122
//
122123
// You can easily build integration and unit tests for your controllers and
123124
// webhooks using the test Environment (pkg/envtest). This will automatically

example_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func Example() {
6464
// This application controller will be running leader election with the provided configuration in the manager options.
6565
// If leader election configuration is not provided, controller runs leader election with default values.
6666
// Default values taken from: https://github.com/kubernetes/component-base/blob/master/config/v1alpha1/defaults.go
67-
// defaultLeaseDuration = 15 * time.Second
68-
// defaultRenewDeadline = 10 * time.Second
69-
// defaultRetryPeriod = 2 * time.Second
67+
// * defaultLeaseDuration = 15 * time.Second
68+
// * defaultRenewDeadline = 10 * time.Second
69+
// * defaultRetryPeriod = 2 * time.Second
7070
//
7171
// * Create a new application for ReplicaSets that manages Pods owned by the ReplicaSet and calls into
7272
// ReplicaSetReconciler.

pkg/cache/cache.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ func New(config *rest.Config, opts Options) (Cache, error) {
170170
// BuilderWithOptions returns a Cache constructor that will build the a cache
171171
// honoring the options argument, this is useful to specify options like
172172
// SelectorsByObject
173-
// WARNING: if SelectorsByObject is specified. filtered out resources are not
174-
// returned.
175-
// WARNING: if UnsafeDisableDeepCopy is enabled, you must DeepCopy any object
176-
// returned from cache get/list before mutating it.
173+
// WARNING: If SelectorsByObject is specified, filtered out resources are not
174+
// returned.
175+
// WARNING: If UnsafeDisableDeepCopy is enabled, you must DeepCopy any object
176+
// returned from cache get/list before mutating it.
177177
func BuilderWithOptions(options Options) NewCacheFunc {
178178
return func(config *rest.Config, opts Options) (Cache, error) {
179179
if options.Scheme == nil {

pkg/client/config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747
// It also applies saner defaults for QPS and burst based on the Kubernetes
4848
// controller manager defaults (20 QPS, 30 burst)
4949
//
50-
// Config precedence
50+
// Config precedence:
5151
//
5252
// * --kubeconfig flag pointing at a file
5353
//
@@ -67,7 +67,7 @@ func GetConfig() (*rest.Config, error) {
6767
// It also applies saner defaults for QPS and burst based on the Kubernetes
6868
// controller manager defaults (20 QPS, 30 burst)
6969
//
70-
// Config precedence
70+
// Config precedence:
7171
//
7272
// * --kubeconfig flag pointing at a file
7373
//

pkg/client/doc.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
// Package client contains functionality for interacting with Kubernetes API
1818
// servers.
1919
//
20-
// Clients
20+
// # Clients
2121
//
2222
// Clients are split into two interfaces -- Readers and Writers. Readers
2323
// get and list, while writers create, update, and delete.
@@ -29,14 +29,15 @@ limitations under the License.
2929
// server. This pattern is covered by the DelegatingClient type, which can
3030
// be used to have a client whose Reader is different from the Writer.
3131
//
32-
// Options
32+
// # Options
3333
//
3434
// Many client operations in Kubernetes support options. These options are
3535
// represented as variadic arguments at the end of a given method call.
3636
// For instance, to use a label selector on list, you can call
37-
// err := someReader.List(context.Background(), &podList, client.MatchingLabels{"somelabel": "someval"})
3837
//
39-
// Indexing
38+
// err := someReader.List(context.Background(), &podList, client.MatchingLabels{"somelabel": "someval"})
39+
//
40+
// # Indexing
4041
//
4142
// Indexes may be added to caches using a FieldIndexer. This allows you to easily
4243
// and efficiently look up objects with certain properties. You can then make

pkg/client/fake/doc.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ When in doubt, it's almost always better not to use this package and instead use
2828
envtest.Environment with a real client and API server.
2929
3030
WARNING: ⚠️ Current Limitations / Known Issues with the fake Client ⚠️
31-
- This client does not have a way to inject specific errors to test handled vs. unhandled errors.
32-
- There is some support for sub resources which can cause issues with tests if you're trying to update
33-
e.g. metadata and status in the same reconcile.
34-
- No OpenAPI validation is performed when creating or updating objects.
35-
- ObjectMeta's `Generation` and `ResourceVersion` don't behave properly, Patch or Update
36-
operations that rely on these fields will fail, or give false positives.
37-
31+
- This client does not have a way to inject specific errors to test handled vs. unhandled errors.
32+
- There is some support for sub resources which can cause issues with tests if you're trying to update
33+
e.g. metadata and status in the same reconcile.
34+
- No OpenAPI validation is performed when creating or updating objects.
35+
- ObjectMeta's `Generation` and `ResourceVersion` don't behave properly, Patch or Update
36+
operations that rely on these fields will fail, or give false positives.
3837
*/
3938
package fake

pkg/config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ type DeferredFileLoader struct {
5050
// this will also configure the defaults for the loader if nothing is
5151
//
5252
// Defaults:
53-
// Path: "./config.yaml"
54-
// Kind: GenericControllerManagerConfiguration
53+
// * Path: "./config.yaml"
54+
// * Kind: GenericControllerManagerConfiguration
5555
func File() *DeferredFileLoader {
5656
scheme := runtime.NewScheme()
5757
utilruntime.Must(v1alpha1.AddToScheme(scheme))

pkg/config/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
// Package config contains functionality for interacting with ComponentConfig
1818
// files
1919
//
20-
// DeferredFileLoader
20+
// # DeferredFileLoader
2121
//
2222
// This uses a deferred file decoding allowing you to chain your configuration
2323
// setup. You can pass this into manager.Options#File and it will load your

pkg/controller/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
/*
1818
Package controller provides types and functions for building Controllers. Controllers implement Kubernetes APIs.
1919
20-
Creation
20+
# Creation
2121
2222
To create a new Controller, first create a manager.Manager and pass it to the controller.New function.
2323
The Controller MUST be started by calling Manager.Start.

pkg/doc.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ limitations under the License.
1818
Package pkg provides libraries for building Controllers. Controllers implement Kubernetes APIs
1919
and are foundational to building Operators, Workload APIs, Configuration APIs, Autoscalers, and more.
2020
21-
Client
21+
# Client
2222
2323
Client provides a Read + Write client for reading and writing Kubernetes objects.
2424
25-
Cache
25+
# Cache
2626
2727
Cache provides a Read client for reading objects from a local cache.
2828
A cache may register handlers to respond to events that update the cache.
2929
30-
Manager
30+
# Manager
3131
3232
Manager is required for creating a Controller and provides the Controller shared dependencies such as
3333
clients, caches, schemes, etc. Controllers should be Started through the Manager by calling Manager.Start.
3434
35-
Controller
35+
# Controller
3636
3737
Controller implements a Kubernetes API by responding to events (object Create, Update, Delete) and ensuring that
3838
the state specified in the Spec of the object matches the state of the system. This is called a reconcile.
@@ -49,7 +49,7 @@ system must be read for each reconcile.
4949
5050
* Controllers require Watches to be configured to enqueue reconcile.Requests in response to events.
5151
52-
Webhook
52+
# Webhook
5353
5454
Admission Webhooks are a mechanism for extending kubernetes APIs. Webhooks can be configured with target
5555
event type (object Create, Update, Delete), the API server will send AdmissionRequests to them
@@ -62,7 +62,7 @@ Validating webhook is used to validate if an object meets certain requirements.
6262
6363
* Admission Webhooks require Handler(s) to be provided to process the received AdmissionReview requests.
6464
65-
Reconciler
65+
# Reconciler
6666
6767
Reconciler is a function provided to a Controller that may be called at anytime with the Name and Namespace of an object.
6868
When called, the Reconciler will ensure that the state of the system matches what is specified in the object at the
@@ -84,7 +84,7 @@ a mapping (e.g. owner references) that maps the object that triggers the reconci
8484
- e.g. it doesn't matter whether a ReplicaSet was created or updated, Reconciler will always compare the number of
8585
Pods in the system against what is specified in the object at the time it is called.
8686
87-
Source
87+
# Source
8888
8989
resource.Source is an argument to Controller.Watch that provides a stream of events.
9090
Events typically come from watching Kubernetes APIs (e.g. Pod Create, Update, Delete).
@@ -97,7 +97,7 @@ through the Watch API.
9797
9898
* Users SHOULD only use the provided Source implementations instead of implementing their own for nearly all cases.
9999
100-
EventHandler
100+
# EventHandler
101101
102102
handler.EventHandler is an argument to Controller.Watch that enqueues reconcile.Requests in response to events.
103103
@@ -117,7 +117,7 @@ type - e.g. map a Node event to objects that respond to cluster resize events.
117117
* Users SHOULD only use the provided EventHandler implementations instead of implementing their own for almost
118118
all cases.
119119
120-
Predicate
120+
# Predicate
121121
122122
predicate.Predicate is an optional argument to Controller.Watch that filters events. This allows common filters to be
123123
reused and composed.
@@ -129,7 +129,7 @@ reused and composed.
129129
* Users SHOULD use the provided Predicate implementations, but MAY implement additional
130130
Predicates e.g. generation changed, label selectors changed etc.
131131
132-
PodController Diagram
132+
# PodController Diagram
133133
134134
Source provides event:
135135
@@ -143,14 +143,14 @@ Reconciler is called with the Request:
143143
144144
* Reconciler(reconcile.Request{types.NamespaceName{Name: "foo", Namespace: "bar"}})
145145
146-
Usage
146+
# Usage
147147
148148
The following example shows creating a new Controller program which Reconciles ReplicaSet objects in response
149149
to Pod or ReplicaSet events. The Reconciler function simply adds a label to the ReplicaSet.
150150
151151
See the examples/builtins/main.go for a usage example.
152152
153-
Controller Example
153+
Controller Example:
154154
155155
1. Watch ReplicaSet and Pods Sources
156156
@@ -167,7 +167,7 @@ Owning ReplicaSet Namespace and Name.
167167
168168
2.3 Reconciler triggered by deletion of Pods from some other actor -> Read ReplicaSet and Pods, create replacement Pods.
169169
170-
Watching and EventHandling
170+
# Watching and EventHandling
171171
172172
Controllers may Watch multiple Kinds of objects (e.g. Pods, ReplicaSets and Deployments), but they reconcile
173173
only a single Type. When one Type of object must be updated in response to changes in another Type of object,
@@ -185,7 +185,7 @@ Note: reconcile.Requests are deduplicated when they are enqueued. Many Pod Even
185185
may trigger only 1 reconcile invocation as each Event results in the Handler trying to enqueue
186186
the same reconcile.Request for the ReplicaSet.
187187
188-
Controller Writing Tips
188+
# Controller Writing Tips
189189
190190
Reconciler Runtime Complexity:
191191

0 commit comments

Comments
 (0)