Skip to content

Commit a44dbea

Browse files
committed
Update controller-runtime to v0.15.1
This is not quite the most recent version of controller-runtime, but it's recent enough, and it's the version compatible with sig.k8s.io/cluster-api, which I would like to introduce. In newer releases, there are some problems with kubeyaml's openapi package that I don't want to deal with right now. The changes to patch up are: - the builder package uses `Watch(client.Object, ...)` rather than `Watch(source.Source, ...)` - `handler.MapFunc` now takes a `context.Context` as the first arguments, so you don't have to use `context.Background` There's also some change to how Kubernetes events get stringified, which broke a test (in notification_test.go). Signed-off-by: Michael Bridgen <[email protected]>
1 parent b75c5f1 commit a44dbea

File tree

8 files changed

+342
-532
lines changed

8 files changed

+342
-532
lines changed

controllers/leveltriggered/controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sigs.k8s.io/controller-runtime/pkg/client"
1818
"sigs.k8s.io/controller-runtime/pkg/handler"
1919
"sigs.k8s.io/controller-runtime/pkg/log"
20-
"sigs.k8s.io/controller-runtime/pkg/source"
2120

2221
"github.com/weaveworks/pipeline-controller/api/v1alpha1"
2322
"github.com/weaveworks/pipeline-controller/pkg/conditions"
@@ -408,11 +407,11 @@ func (r *PipelineReconciler) SetupWithManager(mgr ctrl.Manager) error {
408407
return ctrl.NewControllerManagedBy(mgr).
409408
For(&v1alpha1.Pipeline{}).
410409
Watches(
411-
&source.Kind{Type: &clusterctrlv1alpha1.GitopsCluster{}},
410+
&clusterctrlv1alpha1.GitopsCluster{},
412411
handler.EnqueueRequestsFromMapFunc(r.requestsForCluster(gitopsClusterIndexKey)),
413412
).
414413
Watches(
415-
&source.Kind{Type: &helmv2.HelmRelease{}},
414+
&helmv2.HelmRelease{},
416415
handler.EnqueueRequestsFromMapFunc(r.requestsForApplication),
417416
).
418417
Complete(r)

controllers/leveltriggered/indexing.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ func (r *PipelineReconciler) indexClusterKind(kind string) func(o client.Object)
4141

4242
// requestsForCluster returns a func that will look up the pipelines
4343
// using a cluster, as indexed by `indexClusterKind`.
44-
func (r *PipelineReconciler) requestsForCluster(indexKey string) func(obj client.Object) []reconcile.Request {
45-
return func(obj client.Object) []reconcile.Request {
46-
ctx := context.Background()
44+
func (r *PipelineReconciler) requestsForCluster(indexKey string) func(context.Context, client.Object) []reconcile.Request {
45+
return func(ctx context.Context, obj client.Object) []reconcile.Request {
4746
var list v1alpha1.PipelineList
4847
key := fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName())
4948
if err := r.List(ctx, &list, client.MatchingFields{
@@ -101,8 +100,7 @@ func (r *PipelineReconciler) indexApplication(o client.Object) []string {
101100

102101
// requestsForApplication is given an application object, and looks up the pipeline(s) that use it as a target,
103102
// assuming they are indexed using indexApplication (or something using the same key format and index).
104-
func (r *PipelineReconciler) requestsForApplication(obj client.Object) []reconcile.Request {
105-
ctx := context.Background()
103+
func (r *PipelineReconciler) requestsForApplication(ctx context.Context, obj client.Object) []reconcile.Request {
106104
var list v1alpha1.PipelineList
107105
gvk, err := apiutil.GVKForObject(obj, r.Scheme)
108106
if err != nil {

controllers/pipeline_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/client"
1717
"sigs.k8s.io/controller-runtime/pkg/handler"
1818
"sigs.k8s.io/controller-runtime/pkg/log"
19-
"sigs.k8s.io/controller-runtime/pkg/source"
2019

2120
"github.com/weaveworks/pipeline-controller/api/v1alpha1"
2221
"github.com/weaveworks/pipeline-controller/pkg/conditions"
@@ -213,7 +212,7 @@ func (r *PipelineReconciler) SetupWithManager(mgr ctrl.Manager) error {
213212
return ctrl.NewControllerManagedBy(mgr).
214213
For(&v1alpha1.Pipeline{}).
215214
Watches(
216-
&source.Kind{Type: &clusterctrlv1alpha1.GitopsCluster{}},
215+
&clusterctrlv1alpha1.GitopsCluster{},
217216
handler.EnqueueRequestsFromMapFunc(r.requestsForCluster(gitopsClusterIndexKey)),
218217
).
219218
Complete(r)

controllers/pipeline_indexing.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ func (r *PipelineReconciler) indexClusterKind(kind string) func(o client.Object)
3939

4040
// requestsForCluster returns a func that will look up the pipelines
4141
// using a cluster, as indexed by `indexClusterKind`.
42-
func (r *PipelineReconciler) requestsForCluster(indexKey string) func(obj client.Object) []reconcile.Request {
43-
return func(obj client.Object) []reconcile.Request {
44-
ctx := context.Background()
42+
func (r *PipelineReconciler) requestsForCluster(indexKey string) func(context.Context, client.Object) []reconcile.Request {
43+
return func(ctx context.Context, obj client.Object) []reconcile.Request {
4544
var list v1alpha1.PipelineList
4645
key := fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName())
4746
if err := r.List(ctx, &list, client.MatchingFields{

go.mod

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,47 @@ require (
1717
github.com/fluxcd/pkg/runtime v0.19.0
1818
github.com/go-git/go-billy/v5 v5.4.1
1919
github.com/go-git/go-git/v5 v5.6.1
20-
github.com/go-logr/logr v1.2.3
20+
github.com/go-logr/logr v1.2.4
2121
github.com/go-logr/stdr v1.2.2
2222
github.com/google/go-github/v32 v32.1.0
2323
github.com/google/go-github/v49 v49.1.0
2424
github.com/hashicorp/go-uuid v1.0.3
2525
github.com/jenkins-x/go-scm v1.13.12
26-
github.com/onsi/gomega v1.27.4
26+
github.com/onsi/gomega v1.27.8
2727
github.com/spf13/pflag v1.0.5
28-
github.com/spf13/viper v1.15.0
29-
github.com/stretchr/testify v1.8.2
28+
github.com/spf13/viper v1.16.0
29+
github.com/stretchr/testify v1.8.3
3030
github.com/weaveworks/cluster-controller v1.3.0
3131
github.com/weaveworks/pipeline-controller/api v0.0.0
3232
github.com/xanzy/go-gitlab v0.78.0
3333
go.uber.org/mock v0.3.0
34-
golang.org/x/oauth2 v0.6.0
35-
k8s.io/api v0.25.2
36-
k8s.io/apimachinery v0.27.0-beta.0
37-
k8s.io/client-go v0.25.2
38-
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a
39-
sigs.k8s.io/controller-runtime v0.13.0
40-
sigs.k8s.io/kustomize/kyaml v0.13.9
34+
golang.org/x/oauth2 v0.10.0
35+
k8s.io/api v0.27.2
36+
k8s.io/apimachinery v0.27.2
37+
k8s.io/client-go v0.27.2
38+
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f
39+
sigs.k8s.io/controller-runtime v0.15.1
40+
sigs.k8s.io/kustomize/kyaml v0.14.1
4141
)
4242

4343
require (
44-
cloud.google.com/go/compute v1.18.0 // indirect
45-
cloud.google.com/go/compute/metadata v0.2.3 // indirect
4644
code.gitea.io/sdk/gitea v0.14.0 // indirect
47-
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
48-
github.com/Azure/go-autorest/autorest v0.11.28 // indirect
49-
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
50-
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
51-
github.com/Azure/go-autorest/logger v0.2.1 // indirect
52-
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
53-
github.com/Masterminds/semver/v3 v3.1.1 // indirect
45+
github.com/Masterminds/semver/v3 v3.2.0 // indirect
5446
github.com/Microsoft/go-winio v0.5.2 // indirect
5547
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
5648
github.com/acomagu/bufpipe v1.0.4 // indirect
5749
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
5850
github.com/beorn7/perks v1.0.1 // indirect
5951
github.com/bluekeyes/go-gitdiff v0.7.1 // indirect
60-
github.com/cespare/xxhash/v2 v2.1.2 // indirect
52+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
6153
github.com/cloudflare/circl v1.1.0 // indirect
6254
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
6355
github.com/davecgh/go-spew v1.1.1 // indirect
64-
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
56+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
6557
github.com/emirpasic/gods v1.18.1 // indirect
6658
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
6759
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
60+
github.com/fatih/color v1.15.0 // indirect
6861
github.com/fluxcd/gitkit v0.6.0 // indirect
6962
github.com/fluxcd/image-reflector-controller/api v0.22.0 // indirect
7063
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
@@ -73,15 +66,14 @@ require (
7366
github.com/fluxcd/pkg/ssh v0.6.0 // indirect
7467
github.com/fluxcd/pkg/version v0.2.0 // indirect
7568
github.com/fsnotify/fsnotify v1.6.0 // indirect
76-
github.com/go-errors/errors v1.0.1 // indirect
69+
github.com/go-errors/errors v1.4.2 // indirect
7770
github.com/go-git/gcfg v1.5.0 // indirect
78-
github.com/go-logr/zapr v1.2.3 // indirect
71+
github.com/go-logr/zapr v1.2.4 // indirect
7972
github.com/go-openapi/jsonpointer v0.19.6 // indirect
8073
github.com/go-openapi/jsonreference v0.20.1 // indirect
8174
github.com/go-openapi/swag v0.22.3 // indirect
8275
github.com/gofrs/uuid v4.2.0+incompatible // indirect
8376
github.com/gogo/protobuf v1.3.2 // indirect
84-
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
8577
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
8678
github.com/golang/protobuf v1.5.3 // indirect
8779
github.com/google/gnostic v0.6.9 // indirect
@@ -104,53 +96,56 @@ require (
10496
github.com/kevinburke/ssh_config v1.2.0 // indirect
10597
github.com/magiconair/properties v1.8.7 // indirect
10698
github.com/mailru/easyjson v0.7.7 // indirect
107-
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
99+
github.com/mattn/go-colorable v0.1.13 // indirect
100+
github.com/mattn/go-isatty v0.0.17 // indirect
101+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
108102
github.com/mitchellh/copystructure v1.2.0 // indirect
109103
github.com/mitchellh/mapstructure v1.5.0 // indirect
110104
github.com/mitchellh/reflectwalk v1.0.2 // indirect
111105
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
112106
github.com/modern-go/reflect2 v1.0.2 // indirect
113107
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
114108
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
109+
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
115110
github.com/opencontainers/go-digest v1.0.0 // indirect
116-
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
111+
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
117112
github.com/pjbgf/sha1cd v0.3.0 // indirect
118113
github.com/pkg/errors v0.9.1 // indirect
119114
github.com/pmezard/go-difflib v1.0.0 // indirect
120-
github.com/prometheus/client_golang v1.13.0 // indirect
121-
github.com/prometheus/client_model v0.2.0 // indirect
122-
github.com/prometheus/common v0.37.0 // indirect
123-
github.com/prometheus/procfs v0.8.0 // indirect
115+
github.com/prometheus/client_golang v1.16.0 // indirect
116+
github.com/prometheus/client_model v0.4.0 // indirect
117+
github.com/prometheus/common v0.42.0 // indirect
118+
github.com/prometheus/procfs v0.10.1 // indirect
124119
github.com/sergi/go-diff v1.2.0 // indirect
125120
github.com/shurcooL/githubv4 v0.0.0-20190718010115-4ba037080260 // indirect
126121
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
127122
github.com/sirupsen/logrus v1.9.0 // indirect
128123
github.com/skeema/knownhosts v1.1.0 // indirect
129-
github.com/spf13/afero v1.9.3 // indirect
130-
github.com/spf13/cast v1.5.0 // indirect
124+
github.com/spf13/afero v1.9.5 // indirect
125+
github.com/spf13/cast v1.5.1 // indirect
131126
github.com/spf13/jwalterweatherman v1.1.0 // indirect
132127
github.com/subosito/gotenv v1.4.2 // indirect
133128
github.com/xanzy/ssh-agent v0.3.3 // indirect
134129
github.com/xlab/treeprint v1.1.0 // indirect
135130
go.uber.org/atomic v1.10.0 // indirect
136131
go.uber.org/multierr v1.8.0 // indirect
137-
go.uber.org/zap v1.23.0 // indirect
132+
go.uber.org/zap v1.24.0 // indirect
138133
golang.org/x/crypto v0.14.0 // indirect
139134
golang.org/x/net v0.17.0 // indirect
140135
golang.org/x/sys v0.13.0 // indirect
141136
golang.org/x/term v0.13.0 // indirect
142137
golang.org/x/text v0.13.0 // indirect
143138
golang.org/x/time v0.3.0 // indirect
144-
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
139+
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
145140
google.golang.org/appengine v1.6.7 // indirect
146-
google.golang.org/protobuf v1.28.1 // indirect
141+
google.golang.org/protobuf v1.31.0 // indirect
147142
gopkg.in/inf.v0 v0.9.1 // indirect
148143
gopkg.in/ini.v1 v1.67.0 // indirect
149144
gopkg.in/warnings.v0 v0.1.2 // indirect
150145
gopkg.in/yaml.v2 v2.4.0 // indirect
151146
gopkg.in/yaml.v3 v3.0.1 // indirect
152-
k8s.io/apiextensions-apiserver v0.25.2 // indirect
153-
k8s.io/component-base v0.25.2 // indirect
147+
k8s.io/apiextensions-apiserver v0.27.2 // indirect
148+
k8s.io/component-base v0.27.2 // indirect
154149
k8s.io/klog/v2 v2.90.1 // indirect
155150
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
156151
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect

0 commit comments

Comments
 (0)