8
8
"github.com/openservicemesh/osm/pkg/apis/config/v1alpha2"
9
9
"github.com/openservicemesh/osm/pkg/certificate"
10
10
"github.com/openservicemesh/osm/pkg/k8s/informers"
11
+ "github.com/rs/zerolog/log"
11
12
)
12
13
13
14
// MRCComposer is a composer object that allows consumers
@@ -41,11 +42,16 @@ func (m *MRCComposer) List() ([]*v1alpha2.MeshRootCertificate, error) {
41
42
// from the informerCollection's MRC store. Channels returned from multiple invocations of
42
43
// Watch() are unique and have no coordination with each other. Events are guaranteed
43
44
// to be ordered for any particular resources, but NOT across different resources.
44
- func (m * MRCComposer ) Watch (ctx context.Context ) (<- chan certificate.MRCEvent , error ) {
45
+ func (m * MRCComposer ) Watch (ctx context.Context , namespace string ) (<- chan certificate.MRCEvent , error ) {
45
46
eventChan := make (chan certificate.MRCEvent )
46
47
m .informerCollection .AddEventHandler (informers .InformerKeyMeshRootCertificate , cache.ResourceEventHandlerFuncs {
47
48
AddFunc : func (obj interface {}) {
49
+ log .Debug ().Msg ("received MRC add event" )
48
50
mrc := obj .(* v1alpha2.MeshRootCertificate )
51
+ // If there's a specific namespace passed in don't send the MRCEvent unless the MRC's namespace matches
52
+ if namespace != "" && mrc .GetNamespace () != namespace {
53
+ return
54
+ }
49
55
eventChan <- certificate.MRCEvent {
50
56
Type : certificate .MRCEventAdded ,
51
57
MRC : mrc ,
@@ -54,7 +60,11 @@ func (m *MRCComposer) Watch(ctx context.Context) (<-chan certificate.MRCEvent, e
54
60
// We don't really care about the previous version
55
61
// since the "state machine" of the MRC is well defined
56
62
UpdateFunc : func (_ , newObj interface {}) {
63
+ log .Debug ().Msg ("received MRC update event" )
57
64
mrc := newObj .(* v1alpha2.MeshRootCertificate )
65
+ if namespace != "" && mrc .GetNamespace () != namespace {
66
+ return
67
+ }
58
68
eventChan <- certificate.MRCEvent {
59
69
Type : certificate .MRCEventUpdated ,
60
70
MRC : mrc ,
0 commit comments