Skip to content

Commit 4cfbfff

Browse files
Merge branch 'master' into filter-predicate
2 parents 37a7265 + 1095de6 commit 4cfbfff

File tree

103 files changed

+1174
-1147
lines changed

Some content is hidden

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

103 files changed

+1174
-1147
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<!-- please add a :running: (`:running:`) to the title of this PR, and delete this line and similar ones -->
1+
<!-- please add a :seedling: (`:seedling:`) to the title of this PR, and delete this line and similar ones -->
22

33
<!-- What does this do, and why do we need it? -->

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<!-- please add a icon to the title of this PR (see VERSIONING.md), and delete this line and similar ones -->
2-
<!-- the icon will be either ⚠ (:warning:, major), ✨ (:sparkles, minor), 🐛 (:bug:, patch), 📖 (:book:, docs), or 🏃 (:running:, other) -->
2+
<!-- the icon will be either ⚠ (:warning:, major), ✨ (:sparkles, minor), 🐛 (:bug:, patch), 📖 (:book:, docs), or 🌱 (:seedling:, other) -->
33

44
<!-- What does this do, and why do we need it? -->

VERSIONING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ a:
9191
- Non-breaking feature: :sparkles: (`:sparkles:`)
9292
- Patch fix: :bug: (`:bug:`)
9393
- Docs: :book: (`:book:`)
94-
- Infra/Tests/Other: :running: (`:running:`)
94+
- Infra/Tests/Other: :seedling: (`:seedling:`)
9595
- No release note: :ghost: (`:ghost:`)
9696

9797
Use :ghost: (no release note) only for the PRs that change or revert unreleased
@@ -156,7 +156,7 @@ after that.
156156

157157
3. Add a release for controller-runtime on GitHub, using those release
158158
notes, with a title of `vX.Y.Z`.
159-
159+
160160
4. Do a similar process for
161161
[controller-tools](https://github.com/kubernetes-sigs/controller-tools)
162162

@@ -210,10 +210,10 @@ converging on a ergonomic API.
210210

211211
- Users will intuitively see `List`, and use that in new projects, even
212212
if it's marked as deprecated.
213-
213+
214214
- Users who don't notice the deprecation may be confused as to the
215215
difference between `List` and `ListParametric`.
216-
216+
217217
- It's not immediately obvious in isolation (e.g. in surrounding code)
218218
why the method is called `ListParametric`, and may cause confusion
219219
when reading code that makes use of that method.
@@ -229,8 +229,8 @@ Development branches:
229229

230230
- don't win us much in terms of maintenance in the case of breaking
231231
changes (we still have to merge/manage multiple branches for development
232-
and stable)
233-
232+
and stable)
233+
234234
- can be confusing to contributors, who often expect master to have the
235235
latest changes.
236236

alias.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ var (
125125
// get any actual logging.
126126
Log = log.Log
127127

128+
// LoggerFromContext returns a logger with predefined values from a context.Context.
129+
//
130+
// This is meant to be used with the context supplied in a struct that satisfies the Reconciler interface.
131+
LoggerFromContext = log.FromContext
132+
128133
// SetLogger sets a concrete logging implementation for all deferred Loggers.
129134
SetLogger = log.SetLogger
130135
)

example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ type ReplicaSetReconciler struct {
116116
// * Read the ReplicaSet
117117
// * Read the Pods
118118
// * Set a Label on the ReplicaSet with the Pod count
119-
func (a *ReplicaSetReconciler) Reconcile(req controllers.Request) (controllers.Result, error) {
119+
func (a *ReplicaSetReconciler) Reconcile(ctx context.Context, req controllers.Request) (controllers.Result, error) {
120120
// Read the ReplicaSet
121121
rs := &appsv1.ReplicaSet{}
122-
err := a.Get(context.TODO(), req.NamespacedName, rs)
122+
err := a.Get(ctx, req.NamespacedName, rs)
123123
if err != nil {
124124
return controllers.Result{}, err
125125
}
126126

127127
// List the Pods matching the PodTemplate Labels
128128
pods := &corev1.PodList{}
129-
err = a.List(context.TODO(), pods, client.InNamespace(req.Namespace), client.MatchingLabels(rs.Spec.Template.Labels))
129+
err = a.List(ctx, pods, client.InNamespace(req.Namespace), client.MatchingLabels(rs.Spec.Template.Labels))
130130
if err != nil {
131131
return controllers.Result{}, err
132132
}

examples/builtins/controller.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"github.com/go-logr/logr"
24-
2523
appsv1 "k8s.io/api/apps/v1"
2624
"k8s.io/apimachinery/pkg/api/errors"
2725
"sigs.k8s.io/controller-runtime/pkg/client"
26+
"sigs.k8s.io/controller-runtime/pkg/log"
2827
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2928
)
3029

3130
// reconcileReplicaSet reconciles ReplicaSets
3231
type reconcileReplicaSet struct {
3332
// client can be used to retrieve objects from the APIServer.
3433
client client.Client
35-
log logr.Logger
3634
}
3735

3836
// Implement reconcile.Reconciler so the controller can reconcile objects
3937
var _ reconcile.Reconciler = &reconcileReplicaSet{}
4038

41-
func (r *reconcileReplicaSet) Reconcile(request reconcile.Request) (reconcile.Result, error) {
39+
func (r *reconcileReplicaSet) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
4240
// set up a convenient log object so we don't have to type request over and over again
43-
log := r.log.WithValues("request", request)
41+
log := log.FromContext(ctx)
4442

4543
// Fetch the ReplicaSet from the cache
4644
rs := &appsv1.ReplicaSet{}

examples/builtins/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ import (
2525
"sigs.k8s.io/controller-runtime/pkg/client/config"
2626
"sigs.k8s.io/controller-runtime/pkg/controller"
2727
"sigs.k8s.io/controller-runtime/pkg/handler"
28-
logf "sigs.k8s.io/controller-runtime/pkg/log"
28+
"sigs.k8s.io/controller-runtime/pkg/log"
2929
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3030
"sigs.k8s.io/controller-runtime/pkg/manager"
3131
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
3232
"sigs.k8s.io/controller-runtime/pkg/source"
3333
"sigs.k8s.io/controller-runtime/pkg/webhook"
3434
)
3535

36-
var log = logf.Log.WithName("example-controller")
36+
func init() {
37+
log.SetLogger(zap.New())
38+
}
3739

3840
func main() {
39-
logf.SetLogger(zap.Logger(false))
40-
entryLog := log.WithName("entrypoint")
41+
entryLog := log.Log.WithName("entrypoint")
4142

4243
// Setup a Manager
4344
entryLog.Info("setting up manager")
@@ -50,7 +51,7 @@ func main() {
5051
// Setup a new controller to reconcile ReplicaSets
5152
entryLog.Info("Setting up controller")
5253
c, err := controller.New("foo-controller", mgr, controller.Options{
53-
Reconciler: &reconcileReplicaSet{client: mgr.GetClient(), log: log.WithName("reconciler")},
54+
Reconciler: &reconcileReplicaSet{client: mgr.GetClient()},
5455
})
5556
if err != nil {
5657
entryLog.Error(err, "unable to set up individual controller")

examples/crd/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,22 @@ import (
2929
ctrl "sigs.k8s.io/controller-runtime"
3030
api "sigs.k8s.io/controller-runtime/examples/crd/pkg"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
32+
"sigs.k8s.io/controller-runtime/pkg/log"
3233
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3334
)
3435

3536
var (
3637
setupLog = ctrl.Log.WithName("setup")
37-
recLog = ctrl.Log.WithName("reconciler")
3838
)
3939

4040
type reconciler struct {
4141
client.Client
4242
scheme *runtime.Scheme
4343
}
4444

45-
func (r *reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
46-
log := recLog.WithValues("chaospod", req.NamespacedName)
45+
func (r *reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
46+
log := log.FromContext(ctx).WithValues("chaospod", req.NamespacedName)
4747
log.V(1).Info("reconciling chaos pod")
48-
ctx := context.Background()
4948

5049
var chaospod api.ChaosPod
5150
if err := r.Get(ctx, req.NamespacedName, &chaospod); err != nil {
@@ -103,7 +102,7 @@ func (r *reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
103102
}
104103

105104
func main() {
106-
ctrl.SetLogger(zap.Logger(true))
105+
ctrl.SetLogger(zap.New())
107106

108107
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{})
109108
if err != nil {

examples/crd/pkg/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package pkg
2020

2121
import (
2222
"k8s.io/apimachinery/pkg/runtime/schema"
23-
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
23+
logf "sigs.k8s.io/controller-runtime/pkg/log"
2424
"sigs.k8s.io/controller-runtime/pkg/scheme"
2525
)
2626

go.mod

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,27 @@ module sigs.k8s.io/controller-runtime
33
go 1.13
44

55
require (
6-
github.com/beorn7/perks v1.0.1 // indirect
76
github.com/evanphx/json-patch v4.5.0+incompatible
87
github.com/fsnotify/fsnotify v1.4.9
9-
github.com/go-logr/logr v0.1.0
10-
github.com/go-logr/zapr v0.1.0
11-
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
12-
github.com/googleapis/gnostic v0.3.1 // indirect
8+
github.com/go-logr/logr v0.2.1-0.20200730175230-ee2de8da5be6
9+
github.com/go-logr/zapr v0.2.0
10+
github.com/google/go-cmp v0.5.1 // indirect
11+
github.com/googleapis/gnostic v0.5.1 // indirect
1312
github.com/hashicorp/golang-lru v0.5.4 // indirect
14-
github.com/imdario/mergo v0.3.9 // indirect
15-
github.com/json-iterator/go v1.1.10 // indirect
16-
github.com/onsi/ginkgo v1.12.1
13+
github.com/imdario/mergo v0.3.10 // indirect
14+
github.com/onsi/ginkgo v1.14.0
1715
github.com/onsi/gomega v1.10.1
18-
github.com/prometheus/client_golang v1.0.0
16+
github.com/prometheus/client_golang v1.7.1
1917
github.com/prometheus/client_model v0.2.0
20-
github.com/prometheus/procfs v0.0.11 // indirect
2118
github.com/spf13/pflag v1.0.5
22-
go.uber.org/atomic v1.4.0 // indirect
23-
go.uber.org/zap v1.10.0
24-
golang.org/x/text v0.3.3 // indirect
25-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
26-
gomodules.xyz/jsonpatch/v2 v2.0.1
27-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
28-
k8s.io/api v0.18.4
29-
k8s.io/apiextensions-apiserver v0.18.4
30-
k8s.io/apimachinery v0.18.4
31-
k8s.io/client-go v0.18.4
32-
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
19+
go.uber.org/zap v1.15.0
20+
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
21+
gomodules.xyz/jsonpatch/v2 v2.1.0
22+
google.golang.org/appengine v1.6.6 // indirect
23+
k8s.io/api v0.19.0-rc.3
24+
k8s.io/apiextensions-apiserver v0.19.0-rc.3
25+
k8s.io/apimachinery v0.19.0-rc.3
26+
k8s.io/client-go v0.19.0-rc.3
27+
k8s.io/utils v0.0.0-20200720150651-0bdb4ca86cbc
3328
sigs.k8s.io/yaml v1.2.0
3429
)
35-
36-
replace github.com/evanphx/json-patch => github.com/evanphx/json-patch v0.0.0-20190815234213-e83c0a1c26c8

0 commit comments

Comments
 (0)