Skip to content

Commit

Permalink
Merge branch 'master' into filter-predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
VenkatRamaraju committed Aug 7, 2020
2 parents 37a7265 + 1095de6 commit 4cfbfff
Show file tree
Hide file tree
Showing 103 changed files with 1,174 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- please add a :running: (`:running:`) to the title of this PR, and delete this line and similar ones -->
<!-- please add a :seedling: (`:seedling:`) to the title of this PR, and delete this line and similar ones -->

<!-- What does this do, and why do we need it? -->
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- please add a icon to the title of this PR (see VERSIONING.md), and delete this line and similar ones -->
<!-- the icon will be either ⚠ (:warning:, major), ✨ (:sparkles, minor), 🐛 (:bug:, patch), 📖 (:book:, docs), or 🏃 (:running:, other) -->
<!-- the icon will be either ⚠ (:warning:, major), ✨ (:sparkles, minor), 🐛 (:bug:, patch), 📖 (:book:, docs), or 🌱 (:seedling:, other) -->

<!-- What does this do, and why do we need it? -->
12 changes: 6 additions & 6 deletions VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ a:
- Non-breaking feature: :sparkles: (`:sparkles:`)
- Patch fix: :bug: (`:bug:`)
- Docs: :book: (`:book:`)
- Infra/Tests/Other: :running: (`:running:`)
- Infra/Tests/Other: :seedling: (`:seedling:`)
- No release note: :ghost: (`:ghost:`)

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

3. Add a release for controller-runtime on GitHub, using those release
notes, with a title of `vX.Y.Z`.

4. Do a similar process for
[controller-tools](https://github.com/kubernetes-sigs/controller-tools)

Expand Down Expand Up @@ -210,10 +210,10 @@ converging on a ergonomic API.

- Users will intuitively see `List`, and use that in new projects, even
if it's marked as deprecated.

- Users who don't notice the deprecation may be confused as to the
difference between `List` and `ListParametric`.

- It's not immediately obvious in isolation (e.g. in surrounding code)
why the method is called `ListParametric`, and may cause confusion
when reading code that makes use of that method.
Expand All @@ -229,8 +229,8 @@ Development branches:

- don't win us much in terms of maintenance in the case of breaking
changes (we still have to merge/manage multiple branches for development
and stable)
and stable)

- can be confusing to contributors, who often expect master to have the
latest changes.

Expand Down
5 changes: 5 additions & 0 deletions alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ var (
// get any actual logging.
Log = log.Log

// LoggerFromContext returns a logger with predefined values from a context.Context.
//
// This is meant to be used with the context supplied in a struct that satisfies the Reconciler interface.
LoggerFromContext = log.FromContext

// SetLogger sets a concrete logging implementation for all deferred Loggers.
SetLogger = log.SetLogger
)
6 changes: 3 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ type ReplicaSetReconciler struct {
// * Read the ReplicaSet
// * Read the Pods
// * Set a Label on the ReplicaSet with the Pod count
func (a *ReplicaSetReconciler) Reconcile(req controllers.Request) (controllers.Result, error) {
func (a *ReplicaSetReconciler) Reconcile(ctx context.Context, req controllers.Request) (controllers.Result, error) {
// Read the ReplicaSet
rs := &appsv1.ReplicaSet{}
err := a.Get(context.TODO(), req.NamespacedName, rs)
err := a.Get(ctx, req.NamespacedName, rs)
if err != nil {
return controllers.Result{}, err
}

// List the Pods matching the PodTemplate Labels
pods := &corev1.PodList{}
err = a.List(context.TODO(), pods, client.InNamespace(req.Namespace), client.MatchingLabels(rs.Spec.Template.Labels))
err = a.List(ctx, pods, client.InNamespace(req.Namespace), client.MatchingLabels(rs.Spec.Template.Labels))
if err != nil {
return controllers.Result{}, err
}
Expand Down
8 changes: 3 additions & 5 deletions examples/builtins/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,25 @@ import (
"context"
"fmt"

"github.com/go-logr/logr"

appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

// reconcileReplicaSet reconciles ReplicaSets
type reconcileReplicaSet struct {
// client can be used to retrieve objects from the APIServer.
client client.Client
log logr.Logger
}

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

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

// Fetch the ReplicaSet from the cache
rs := &appsv1.ReplicaSet{}
Expand Down
11 changes: 6 additions & 5 deletions examples/builtins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
"sigs.k8s.io/controller-runtime/pkg/source"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

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

func main() {
logf.SetLogger(zap.Logger(false))
entryLog := log.WithName("entrypoint")
entryLog := log.Log.WithName("entrypoint")

// Setup a Manager
entryLog.Info("setting up manager")
Expand All @@ -50,7 +51,7 @@ func main() {
// Setup a new controller to reconcile ReplicaSets
entryLog.Info("Setting up controller")
c, err := controller.New("foo-controller", mgr, controller.Options{
Reconciler: &reconcileReplicaSet{client: mgr.GetClient(), log: log.WithName("reconciler")},
Reconciler: &reconcileReplicaSet{client: mgr.GetClient()},
})
if err != nil {
entryLog.Error(err, "unable to set up individual controller")
Expand Down
9 changes: 4 additions & 5 deletions examples/crd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
api "sigs.k8s.io/controller-runtime/examples/crd/pkg"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)

var (
setupLog = ctrl.Log.WithName("setup")
recLog = ctrl.Log.WithName("reconciler")
)

type reconciler struct {
client.Client
scheme *runtime.Scheme
}

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

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

func main() {
ctrl.SetLogger(zap.Logger(true))
ctrl.SetLogger(zap.New())

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/crd/pkg/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package pkg

import (
"k8s.io/apimachinery/pkg/runtime/schema"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

Expand Down
39 changes: 16 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,27 @@ module sigs.k8s.io/controller-runtime
go 1.13

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/fsnotify/fsnotify v1.4.9
github.com/go-logr/logr v0.1.0
github.com/go-logr/zapr v0.1.0
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/go-logr/logr v0.2.1-0.20200730175230-ee2de8da5be6
github.com/go-logr/zapr v0.2.0
github.com/google/go-cmp v0.5.1 // indirect
github.com/googleapis/gnostic v0.5.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/onsi/ginkgo v1.12.1
github.com/imdario/mergo v0.3.10 // indirect
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/procfs v0.0.11 // indirect
github.com/spf13/pflag v1.0.5
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/zap v1.10.0
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
gomodules.xyz/jsonpatch/v2 v2.0.1
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
k8s.io/api v0.18.4
k8s.io/apiextensions-apiserver v0.18.4
k8s.io/apimachinery v0.18.4
k8s.io/client-go v0.18.4
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
go.uber.org/zap v1.15.0
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
gomodules.xyz/jsonpatch/v2 v2.1.0
google.golang.org/appengine v1.6.6 // indirect
k8s.io/api v0.19.0-rc.3
k8s.io/apiextensions-apiserver v0.19.0-rc.3
k8s.io/apimachinery v0.19.0-rc.3
k8s.io/client-go v0.19.0-rc.3
k8s.io/utils v0.0.0-20200720150651-0bdb4ca86cbc
sigs.k8s.io/yaml v1.2.0
)

replace github.com/evanphx/json-patch => github.com/evanphx/json-patch v0.0.0-20190815234213-e83c0a1c26c8
Loading

0 comments on commit 4cfbfff

Please sign in to comment.