watcher filter GetTenantNameFromObj
@@ -103,8 +103,13 @@ func buildNamespaceResMessage(c *Client, action string, objWatched interface{})
return nil, nil
}
- tenant, tenantExist := namespace.Labels["tenant"]
- if !tenantExist || tenant != c.clientInfo.Tenant {
+ tenantName, err := v1alpha1.GetTenantNameFromObj(namespace)
+
+ if err != nil {
+ return nil, err
+ }
+
+ if tenantName != c.clientInfo.Tenant {
return nil, nil
}
@@ -149,6 +154,16 @@ func buildComponentResMessage(c *Client, action string, objWatched interface{})
return nil, errors.New("convert watch obj to Component failed")
}
+ tenantName, err := v1alpha1.GetTenantNameFromObj(component)
+
+ if err != nil {
+ return nil, err
+ }
+
+ if tenantName != c.clientInfo.Tenant {
+ return nil, nil
+ }
+
if !c.clientManager.CanViewScope(c.clientInfo, c.clientInfo.Tenant+"/"+component.Namespace) {
return nil, nil
}
@@ -168,6 +183,16 @@ func buildComponentResMessageCausedByService(c *Client, action string, objWatche
return nil, nil
}
+ // tenantName, err := v1alpha1.GetTenantNameFromObj(service)
+
+ // if err != nil {
+ // return nil, err
+ // }
+
+ // if tenantName != c.clientInfo.Tenant {
+ // return nil, nil
+ // }
+
if !c.clientManager.CanViewScope(c.clientInfo, c.clientInfo.Tenant+"/"+service.Namespace) {
return nil, nil
}
@@ -188,6 +213,16 @@ func buildServiceResMessage(c *Client, action string, objWatched interface{}) (*
return nil, errors.New("convert watch obj to Service failed")
}
+ // tenantName, err := v1alpha1.GetTenantNameFromObj(service)
+
+ // if err != nil {
+ // return nil, err
+ // }
+
+ // if tenantName != c.clientInfo.Tenant {
+ // return nil, nil
+ // }
+
if !c.clientManager.CanViewScope(c.clientInfo, c.clientInfo.Tenant+"/"+service.Namespace) {
return nil, nil
}
@@ -210,6 +245,16 @@ func buildPodResMessage(c *Client, action string, objWatched interface{}) (*ResM
return &ResMessage{}, nil
}
+ tenantName, err := v1alpha1.GetTenantNameFromObj(pod)
+
+ if err != nil {
+ return nil, err
+ }
+
+ if tenantName != c.clientInfo.Tenant {
+ return nil, nil
+ }
+
if !c.clientManager.CanViewScope(c.clientInfo, c.clientInfo.Tenant+"/"+pod.Namespace) {
return nil, nil
}
@@ -404,6 +449,16 @@ func buildProtectEndpointResMessage(c *Client, action string, objWatched interfa
return nil, errors.New("convert watch obj to ProtectedEndpoint failed")
}
+ tenantName, err := v1alpha1.GetTenantNameFromObj(endpoint)
+
+ if err != nil {
+ return nil, err
+ }
+
+ if tenantName != c.clientInfo.Tenant {
+ return nil, nil
+ }
+
if !c.clientManager.CanViewScope(c.clientInfo, c.clientInfo.Tenant+"/"+endpoint.Namespace) {
return nil, nil
}
