Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 6706777

Browse files
author
odacremolbap
committed
reconcile secret config
1 parent 1f0bba8 commit 6706777

File tree

10 files changed

+393
-28
lines changed

10 files changed

+393
-28
lines changed

config/200-clusterroles.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ rules:
3434
- delete
3535
- patch
3636

37-
# Manage broker services
37+
# Manage broker services and configuration as secrets
3838
- apiGroups:
3939
- ''
4040
resources:
4141
- services
42+
- secrets
4243
verbs:
4344
- get
4445
- list

go.mod

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ module github.com/triggermesh/triggermesh-core
33
go 1.19
44

55
require (
6-
github.com/stretchr/testify v1.7.0
7-
go.uber.org/zap v1.21.0
6+
github.com/stretchr/testify v1.8.0
7+
github.com/triggermesh/brokers v0.0.0-20220926134808-88d6a8629e30
8+
go.uber.org/zap v1.22.0
89
k8s.io/api v0.24.4
910
k8s.io/apimachinery v0.24.4
1011
k8s.io/client-go v0.24.4
1112
k8s.io/code-generator v0.24.4
1213
knative.dev/eventing v0.34.2
1314
knative.dev/pkg v0.0.0-20220914154704-5f66ecf267fe
15+
sigs.k8s.io/yaml v1.3.0
1416
)
1517

1618
require (
@@ -25,7 +27,7 @@ require (
2527
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
2628
github.com/cespare/xxhash/v2 v2.1.2 // indirect
2729
github.com/cloudevents/sdk-go/sql/v2 v2.8.0 // indirect
28-
github.com/cloudevents/sdk-go/v2 v2.10.1 // indirect
30+
github.com/cloudevents/sdk-go/v2 v2.11.0 // indirect
2931
github.com/davecgh/go-spew v1.1.1 // indirect
3032
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
3133
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
@@ -61,8 +63,8 @@ require (
6163
github.com/prometheus/common v0.32.1 // indirect
6264
github.com/prometheus/procfs v0.7.3 // indirect
6365
github.com/prometheus/statsd_exporter v0.21.0 // indirect
64-
github.com/rickb777/date v1.13.0 // indirect
65-
github.com/rickb777/plural v1.2.1 // indirect
66+
github.com/rickb777/date v1.20.0 // indirect
67+
github.com/rickb777/plural v1.4.1 // indirect
6668
github.com/spf13/pflag v1.0.5 // indirect
6769
go.opencensus.io v0.23.0 // indirect
6870
go.uber.org/atomic v1.9.0 // indirect
@@ -71,7 +73,7 @@ require (
7173
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
7274
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
7375
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
74-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
76+
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
7577
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
7678
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
7779
golang.org/x/text v0.3.7 // indirect
@@ -94,5 +96,4 @@ require (
9496
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
9597
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
9698
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
97-
sigs.k8s.io/yaml v1.3.0 // indirect
9899
)

go.sum

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
108108
github.com/cloudevents/sdk-go/sql/v2 v2.8.0 h1:gWednxJHL0Ycf93XeEFyQxYj81A7b4eNwkzjNxGunAM=
109109
github.com/cloudevents/sdk-go/sql/v2 v2.8.0/go.mod h1:u9acNJbhmi1wnDJro4PEAqbr4N1LTCyEUClErxbPS1A=
110110
github.com/cloudevents/sdk-go/v2 v2.8.0/go.mod h1:GpCBmUj7DIRiDhVvsK5d6WCbgTWs8DxAWTRtAwQmIXs=
111-
github.com/cloudevents/sdk-go/v2 v2.10.1 h1:qNFovJ18fWOd8Q9ydWJPk1oiFudXyv1GxJIP7MwPjuM=
112-
github.com/cloudevents/sdk-go/v2 v2.10.1/go.mod h1:GpCBmUj7DIRiDhVvsK5d6WCbgTWs8DxAWTRtAwQmIXs=
111+
github.com/cloudevents/sdk-go/v2 v2.11.0 h1:pCb7Cdkb8XpUoil+miuw6PEzuCG9cc8Erj8y1/q3odo=
112+
github.com/cloudevents/sdk-go/v2 v2.11.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUEeUfapHMUX1T5To=
113113
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
114114
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
115115
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@@ -370,7 +370,6 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
370370
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
371371
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
372372
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
373-
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
374373
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
375374
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
376375
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
@@ -456,10 +455,10 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
456455
github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8=
457456
github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ=
458457
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
459-
github.com/rickb777/date v1.13.0 h1:+8AmwLuY1d/rldzdqvqTEg7107bZ8clW37x4nsdG3Hs=
460-
github.com/rickb777/date v1.13.0/go.mod h1:GZf3LoGnxPWjX+/1TXOuzHefZFDovTyNLHDMd3qH70k=
461-
github.com/rickb777/plural v1.2.1 h1:UitRAgR70+yHFt26Tmj/F9dU9aV6UfjGXSbO1DcC9/U=
462-
github.com/rickb777/plural v1.2.1/go.mod h1:j058+3M5QQFgcZZ2oKIOekcygoZUL8gKW5yRO14BuAw=
458+
github.com/rickb777/date v1.20.0 h1:oRGcq4b+ba12N/HnsVZuWSK/QJb/o/hnjOJEyRMGUT0=
459+
github.com/rickb777/date v1.20.0/go.mod h1:8AR0TBrjDGUjwKToBI8L+RafzNg7gqlT0ox0cERCwEo=
460+
github.com/rickb777/plural v1.4.1 h1:5MMLcbIaapLFmvDGRT5iPk8877hpTPt8Y9cdSKRw9sU=
461+
github.com/rickb777/plural v1.4.1/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw=
463462
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
464463
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
465464
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -489,20 +488,24 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
489488
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
490489
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
491490
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
492-
github.com/sqs/goreturns v0.0.0-20181028201513-538ac6014518/go.mod h1:CKI4AZ4XmGV240rTHfO0hfE83S6/a3/Q1siZJ/vXf7A=
493491
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
494492
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
495493
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
494+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
496495
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
497496
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
498497
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
499498
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
500499
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
501-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
502500
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
501+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
502+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
503+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
503504
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
504505
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
505506
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
507+
github.com/triggermesh/brokers v0.0.0-20220926134808-88d6a8629e30 h1:EjHSGHBT/7hp01nmYd0vNGpIo7vOl1Lm2NRxmc8XQ4k=
508+
github.com/triggermesh/brokers v0.0.0-20220926134808-88d6a8629e30/go.mod h1:64gU9A1hlgsU6/51B3h7eDsg7KI4BvuzAE9uJ8h6V9U=
506509
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
507510
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
508511
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
@@ -552,16 +555,15 @@ go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
552555
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
553556
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
554557
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
555-
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
556558
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
557559
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
558560
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
559561
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
560562
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
561563
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
562564
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
563-
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
564-
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
565+
go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0=
566+
go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U=
565567
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
566568
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
567569
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -689,8 +691,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
689691
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
690692
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
691693
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
692-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
693694
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
695+
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
696+
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
694697
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
695698
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
696699
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -825,7 +828,6 @@ golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjs
825828
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
826829
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
827830
golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
828-
golang.org/x/tools v0.0.0-20200512001501-aaeff5de670a/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
829831
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
830832
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
831833
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

pkg/apis/eventing/v1alpha1/redisbroker_lifecycle.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
RedisBrokerRedisService apis.ConditionType = "RedisServiceReady"
2121
RedisBrokerBrokerDeployment apis.ConditionType = "BrokerDeploymentReady"
2222
RedisBrokerBrokerService apis.ConditionType = "BrokerServiceReady"
23+
RedisBrokerConfigSecret apis.ConditionType = "BrokerConfigSecretReady"
2324
RedisBrokerConditionAddressable apis.ConditionType = "Addressable"
2425
)
2526

@@ -28,6 +29,7 @@ var redisBrokerCondSet = apis.NewLivingConditionSet(
2829
RedisBrokerRedisService,
2930
RedisBrokerBrokerDeployment,
3031
RedisBrokerBrokerService,
32+
RedisBrokerConfigSecret,
3133
RedisBrokerConditionAddressable,
3234
)
3335
var redisBrokerCondSetLock = sync.RWMutex{}
@@ -135,3 +137,15 @@ func (bs *RedisBrokerStatus) MarkRedisServiceUnknown(reason, messageFormat strin
135137
func (bs *RedisBrokerStatus) MarkRedisServiceReady() {
136138
redisBrokerCondSet.Manage(bs).MarkTrue(RedisBrokerRedisService)
137139
}
140+
141+
func (bs *RedisBrokerStatus) MarkConfigSecretFailed(reason, messageFormat string, messageA ...interface{}) {
142+
redisBrokerCondSet.Manage(bs).MarkFalse(RedisBrokerConfigSecret, reason, messageFormat, messageA...)
143+
}
144+
145+
func (bs *RedisBrokerStatus) MarkConfigSecretUnknown(reason, messageFormat string, messageA ...interface{}) {
146+
redisBrokerCondSet.Manage(bs).MarkUnknown(RedisBrokerConfigSecret, reason, messageFormat, messageA...)
147+
}
148+
149+
func (bs *RedisBrokerStatus) MarkConfigSecretReady() {
150+
redisBrokerCondSet.Manage(bs).MarkTrue(RedisBrokerConfigSecret)
151+
}

pkg/apis/eventing/v1alpha1/trigger_lifecycle.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"k8s.io/apimachinery/pkg/runtime/schema"
99
"knative.dev/pkg/apis"
1010
duckv1 "knative.dev/pkg/apis/duck/v1"
11+
"knative.dev/pkg/kmeta"
1112
)
1213

1314
var triggerCondSet = apis.NewLivingConditionSet(TriggerConditionBroker, TriggerConditionTarget, TriggerConditionTargetResolved, TriggerConditionDeadLetterSinkResolved)
@@ -153,3 +154,25 @@ func (ts *TriggerStatus) MarkDeadLetterSinkNotConfigured() {
153154
func (ts *TriggerStatus) MarkDeadLetterSinkResolvedFailed(reason, messageFormat string, messageA ...interface{}) {
154155
triggerCondSet.Manage(ts).MarkFalse(TriggerConditionDeadLetterSinkResolved, reason, messageFormat, messageA...)
155156
}
157+
158+
func (t *Trigger) ReferencesBroker(broker kmeta.OwnerRefable) bool {
159+
gvk := broker.GetGroupVersionKind()
160+
161+
// Require same namespace for Trigger and Broker.
162+
if t.Spec.Broker.Namespace != "" &&
163+
t.Spec.Broker.Namespace != broker.GetObjectMeta().GetNamespace() {
164+
return false
165+
}
166+
167+
// If APIVersion is informed it should match the Broker's.
168+
if t.Spec.Broker.APIVersion != "" {
169+
if t.Spec.Broker.APIVersion != gvk.GroupVersion().String() {
170+
return false
171+
}
172+
} else if t.Spec.Broker.Group != gvk.Group {
173+
return false
174+
}
175+
176+
return t.Spec.Broker.Name == broker.GetObjectMeta().GetName() &&
177+
t.Spec.Broker.Kind == gvk.Kind
178+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright 2022 TriggerMesh Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
package v1alpha1
4+
5+
import (
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
duckv1 "knative.dev/pkg/apis/duck/v1"
12+
)
13+
14+
const (
15+
tBrokerName = "testbroker"
16+
tNamespace = "testnamespace"
17+
)
18+
19+
func TestDoesTriggerRefBroker(t *testing.T) {
20+
rb := &RedisBroker{
21+
TypeMeta: metav1.TypeMeta{
22+
APIVersion: SchemeGroupVersion.String(),
23+
Kind: "RedisBroker",
24+
},
25+
ObjectMeta: metav1.ObjectMeta{
26+
Name: tBrokerName,
27+
Namespace: tNamespace,
28+
},
29+
}
30+
31+
testCases := map[string]struct {
32+
trigger *Trigger
33+
broker *RedisBroker
34+
expected bool
35+
}{
36+
"matching GK and name, using group": {
37+
trigger: &Trigger{
38+
ObjectMeta: metav1.ObjectMeta{
39+
Namespace: tNamespace,
40+
},
41+
Spec: TriggerSpec{
42+
Broker: duckv1.KReference{
43+
Group: "eventing.triggermesh.io",
44+
Kind: "RedisBroker",
45+
Name: tBrokerName,
46+
},
47+
},
48+
},
49+
broker: rb,
50+
expected: true,
51+
},
52+
"matching GVK and name, using APIVersion": {
53+
trigger: &Trigger{
54+
ObjectMeta: metav1.ObjectMeta{
55+
Namespace: tNamespace,
56+
},
57+
Spec: TriggerSpec{
58+
Broker: duckv1.KReference{
59+
APIVersion: "eventing.triggermesh.io/v1alpha1",
60+
Kind: "RedisBroker",
61+
Name: tBrokerName,
62+
},
63+
},
64+
},
65+
broker: rb,
66+
expected: true,
67+
},
68+
"non matching version, using APIVersion": {
69+
trigger: &Trigger{
70+
ObjectMeta: metav1.ObjectMeta{
71+
Namespace: tNamespace,
72+
},
73+
Spec: TriggerSpec{
74+
Broker: duckv1.KReference{
75+
APIVersion: "eventing.triggermesh.io/v1alpha2",
76+
Kind: "RedisBroker",
77+
Name: tBrokerName,
78+
},
79+
},
80+
},
81+
broker: rb,
82+
expected: false,
83+
},
84+
"non matching group, using APIVersion": {
85+
trigger: &Trigger{
86+
ObjectMeta: metav1.ObjectMeta{
87+
Namespace: tNamespace,
88+
},
89+
Spec: TriggerSpec{
90+
Broker: duckv1.KReference{
91+
APIVersion: "test.triggermesh.io/v1alpha1",
92+
Kind: "RedisBroker",
93+
Name: tBrokerName,
94+
},
95+
},
96+
},
97+
broker: rb,
98+
expected: false,
99+
},
100+
"non matching group, using group": {
101+
trigger: &Trigger{
102+
ObjectMeta: metav1.ObjectMeta{
103+
Namespace: tNamespace,
104+
},
105+
Spec: TriggerSpec{
106+
Broker: duckv1.KReference{
107+
Group: "test.triggermesh.io",
108+
Kind: "RedisBroker",
109+
Name: tBrokerName,
110+
},
111+
},
112+
},
113+
broker: rb,
114+
expected: false,
115+
},
116+
"missing group and APIVersion": {
117+
trigger: &Trigger{
118+
ObjectMeta: metav1.ObjectMeta{
119+
Namespace: tNamespace,
120+
},
121+
Spec: TriggerSpec{
122+
Broker: duckv1.KReference{
123+
Kind: "RedisBroker",
124+
Name: tBrokerName,
125+
},
126+
},
127+
},
128+
broker: rb,
129+
expected: false,
130+
},
131+
}
132+
133+
for name, tc := range testCases {
134+
t.Run(name, func(t *testing.T) {
135+
got := tc.trigger.ReferencesBroker(tc.broker)
136+
assert.Equal(t, tc.expected, got)
137+
})
138+
}
139+
}

pkg/reconciler/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const (
2626
ReasonFailedServiceCreate = "FailedServiceCreate"
2727
ReasonFailedServiceUpdate = "FailedServiceUpdate"
2828

29+
ReasonFailedTriggerList = "FailedTriggerList"
30+
ReasonFailedConfigSerialize = "FailedConfigSerialize"
31+
// ReasonServiceUpdate = "UpdateService"
32+
// ReasonFailedServiceGet = "FailedServiceGet"
33+
// ReasonFailedServiceCreate = "FailedServiceCreate"
34+
// ReasonFailedServiceUpdate = "FailedServiceUpdate"
35+
2936
// // ReasonBadSinkURI indicates that the URI of a sink can't be determined.
3037
// ReasonBadSinkURI = "BadSinkURI"
3138

0 commit comments

Comments
 (0)