Skip to content

Commit e2ed630

Browse files
committed
Refactor notifies to use Flux Event API v1beta1
Signed-off-by: Stefan Prodan <[email protected]>
1 parent c3f711a commit e2ed630

Some content is hidden

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

50 files changed

+271
-415
lines changed

controllers/alert_controller_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ import (
3939
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
4040
logf "sigs.k8s.io/controller-runtime/pkg/log"
4141

42+
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
4243
"github.com/fluxcd/pkg/apis/meta"
4344
"github.com/fluxcd/pkg/runtime/conditions"
44-
"github.com/fluxcd/pkg/runtime/events"
4545

4646
apiv1 "github.com/fluxcd/notification-controller/api/v1beta2"
4747
"github.com/fluxcd/notification-controller/internal/server"
@@ -275,7 +275,7 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
275275
return conditions.IsReady(&obj)
276276
}, 30*time.Second, time.Second).Should(BeTrue())
277277

278-
event := events.Event{
278+
event := eventv1.Event{
279279
InvolvedObject: corev1.ObjectReference{
280280
Kind: "Bucket",
281281
Name: "hyacinth",
@@ -315,49 +315,49 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
315315

316316
tests := []struct {
317317
name string
318-
modifyEventFunc func(e events.Event) events.Event
318+
modifyEventFunc func(e eventv1.Event) eventv1.Event
319319
forwarded bool
320320
}{
321321
{
322322
name: "forwards when source is a match",
323-
modifyEventFunc: func(e events.Event) events.Event { return e },
323+
modifyEventFunc: func(e eventv1.Event) eventv1.Event { return e },
324324
forwarded: true,
325325
},
326326
{
327327
name: "drops event when source Kind does not match",
328-
modifyEventFunc: func(e events.Event) events.Event {
328+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
329329
e.InvolvedObject.Kind = "GitRepository"
330330
return e
331331
},
332332
forwarded: false,
333333
},
334334
{
335335
name: "drops event when source name does not match",
336-
modifyEventFunc: func(e events.Event) events.Event {
336+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
337337
e.InvolvedObject.Name = "slop"
338338
return e
339339
},
340340
forwarded: false,
341341
},
342342
{
343343
name: "drops event when source namespace does not match",
344-
modifyEventFunc: func(e events.Event) events.Event {
344+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
345345
e.InvolvedObject.Namespace = "all-buckets"
346346
return e
347347
},
348348
forwarded: false,
349349
},
350350
{
351351
name: "drops event that is matched by exclusion",
352-
modifyEventFunc: func(e events.Event) events.Event {
352+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
353353
e.Message = "this is excluded"
354354
return e
355355
},
356356
forwarded: false,
357357
},
358358
{
359359
name: "forwards events when name wildcard is used",
360-
modifyEventFunc: func(e events.Event) events.Event {
360+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
361361
e.InvolvedObject.Kind = "Kustomization"
362362
e.InvolvedObject.Name = "test"
363363
e.InvolvedObject.Namespace = namespace
@@ -368,7 +368,7 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
368368
},
369369
{
370370
name: "forwards events when the label matches",
371-
modifyEventFunc: func(e events.Event) events.Event {
371+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
372372
e.InvolvedObject.Kind = "GitRepository"
373373
e.InvolvedObject.Name = "podinfo"
374374
e.InvolvedObject.APIVersion = "source.toolkit.fluxcd.io/v1beta1"
@@ -380,7 +380,7 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
380380
},
381381
{
382382
name: "drops events when the labels don't match",
383-
modifyEventFunc: func(e events.Event) events.Event {
383+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
384384
e.InvolvedObject.Kind = "GitRepository"
385385
e.InvolvedObject.Name = "podinfo-two"
386386
e.InvolvedObject.APIVersion = "source.toolkit.fluxcd.io/v1beta1"
@@ -392,7 +392,7 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
392392
},
393393
{
394394
name: "drops events for cross-namespace sources",
395-
modifyEventFunc: func(e events.Event) events.Event {
395+
modifyEventFunc: func(e eventv1.Event) eventv1.Event {
396396
e.InvolvedObject.Kind = "Kustomization"
397397
e.InvolvedObject.Name = "test"
398398
e.InvolvedObject.Namespace = "test"

docs/spec/v1beta2/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In the above example:
4141
## Event structure
4242

4343
The Go type that defines the event structure can be found in the
44-
[fluxcd/pkg/runtime/events](https://github.com/fluxcd/pkg/blob/main/runtime/events/event.go)
44+
[fluxcd/pkg/apis/event/v1beta1](https://github.com/fluxcd/pkg/blob/main/apis/event/v1beta1/event.go)
4545
package.
4646

4747
## Rate limiting

go.mod

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@ go 1.18
55
replace github.com/fluxcd/notification-controller/api => ./api
66

77
require (
8-
github.com/AdaLogics/go-fuzz-headers v0.0.0-20221007124625-37f5449ff7df
8+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20221103172237-443f56ff4ba8
99
github.com/Azure/azure-amqp-common-go/v3 v3.2.3
10-
github.com/Azure/azure-event-hubs-go/v3 v3.3.18
10+
github.com/Azure/azure-event-hubs-go/v3 v3.3.19
1111
github.com/containrrr/shoutrrr v0.6.1
1212
github.com/fluxcd/notification-controller/api v0.28.0
13+
github.com/fluxcd/pkg/apis/event v0.1.0
1314
github.com/fluxcd/pkg/apis/meta v0.17.0
1415
github.com/fluxcd/pkg/masktoken v0.2.0
15-
github.com/fluxcd/pkg/runtime v0.22.0
16+
github.com/fluxcd/pkg/runtime v0.23.0
1617
github.com/fluxcd/pkg/ssa v0.21.0
1718
github.com/getsentry/sentry-go v0.13.0
1819
github.com/go-logr/logr v1.2.3
1920
github.com/google/go-github/v41 v41.0.0
2021
github.com/hashicorp/go-retryablehttp v0.7.1
2122
github.com/ktrysmt/go-bitbucket v0.9.54
2223
github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.1
23-
github.com/onsi/gomega v1.22.1
24+
github.com/onsi/gomega v1.24.0
2425
github.com/sethvargo/go-limiter v0.7.2
2526
github.com/slok/go-http-metrics v0.10.0
2627
github.com/spf13/pflag v1.0.5
27-
github.com/stretchr/testify v1.8.0
28+
github.com/stretchr/testify v1.8.1
2829
github.com/whilp/git-urls v1.0.0
29-
github.com/xanzy/go-gitlab v0.73.1
30+
github.com/xanzy/go-gitlab v0.74.0
3031
golang.org/x/oauth2 v0.1.0
3132
k8s.io/api v0.25.3
3233
k8s.io/apimachinery v0.25.3
3334
k8s.io/client-go v0.25.3
34-
sigs.k8s.io/cli-utils v0.33.0
35-
sigs.k8s.io/controller-runtime v0.13.0
35+
sigs.k8s.io/cli-utils v0.34.0
36+
sigs.k8s.io/controller-runtime v0.13.1
3637
sigs.k8s.io/yaml v1.3.0
3738
)
3839

@@ -55,23 +56,23 @@ replace golang.org/x/crypto => golang.org/x/crypto v0.0.0-20220518034528-6f7dac9
5556

5657
require (
5758
cloud.google.com/go v0.99.0 // indirect
58-
github.com/Azure/azure-sdk-for-go v53.4.0+incompatible // indirect
59+
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible // indirect
5960
github.com/Azure/go-amqp v0.17.0 // indirect
6061
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
6162
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
62-
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
63-
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
63+
github.com/Azure/go-autorest/autorest v0.11.28 // indirect
64+
github.com/Azure/go-autorest/autorest/adal v0.9.21 // indirect
6465
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
6566
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
6667
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
6768
github.com/Azure/go-autorest/logger v0.2.1 // indirect
6869
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
69-
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
70+
github.com/MakeNowJust/heredoc v1.0.0 // indirect
7071
github.com/PuerkitoBio/purell v1.1.1 // indirect
7172
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
7273
github.com/beorn7/perks v1.0.1 // indirect
7374
github.com/cespare/xxhash/v2 v2.1.2 // indirect
74-
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
75+
github.com/chai2010/gettext-go v1.0.2 // indirect
7576
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
7677
github.com/davecgh/go-spew v1.1.1 // indirect
7778
github.com/devigned/tab v0.1.1 // indirect
@@ -88,7 +89,7 @@ require (
8889
github.com/go-openapi/jsonreference v0.19.5 // indirect
8990
github.com/go-openapi/swag v0.19.14 // indirect
9091
github.com/gogo/protobuf v1.3.2 // indirect
91-
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
92+
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
9293
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
9394
github.com/golang/protobuf v1.5.2 // indirect
9495
github.com/google/btree v1.0.1 // indirect
@@ -112,7 +113,7 @@ require (
112113
github.com/mattn/go-isatty v0.0.16 // indirect
113114
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
114115
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
115-
github.com/mitchellh/mapstructure v1.4.3 // indirect
116+
github.com/mitchellh/mapstructure v1.5.0 // indirect
116117
github.com/moby/spdystream v0.2.0 // indirect
117118
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
118119
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -128,7 +129,7 @@ require (
128129
github.com/prometheus/procfs v0.8.0 // indirect
129130
github.com/rogpeppe/go-internal v1.8.0 // indirect
130131
github.com/russross/blackfriday v1.5.2 // indirect
131-
github.com/spf13/cobra v1.4.0 // indirect
132+
github.com/spf13/cobra v1.5.0 // indirect
132133
github.com/xlab/treeprint v1.1.0 // indirect
133134
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
134135
go.uber.org/atomic v1.7.0 // indirect
@@ -146,13 +147,13 @@ require (
146147
gopkg.in/inf.v0 v0.9.1 // indirect
147148
gopkg.in/yaml.v2 v2.4.0 // indirect
148149
gopkg.in/yaml.v3 v3.0.1 // indirect
149-
k8s.io/apiextensions-apiserver v0.25.0 // indirect
150-
k8s.io/cli-runtime v0.25.2 // indirect
151-
k8s.io/component-base v0.25.2 // indirect
150+
k8s.io/apiextensions-apiserver v0.25.3 // indirect
151+
k8s.io/cli-runtime v0.25.3 // indirect
152+
k8s.io/component-base v0.25.3 // indirect
152153
k8s.io/klog/v2 v2.80.1 // indirect
153154
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
154-
k8s.io/kubectl v0.24.0 // indirect
155-
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
155+
k8s.io/kubectl v0.25.3 // indirect
156+
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 // indirect
156157
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
157158
sigs.k8s.io/kustomize/api v0.12.1 // indirect
158159
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect

0 commit comments

Comments
 (0)